Fix app import
This commit is contained in:
@@ -29,17 +29,8 @@ async function onSubmit() {
|
||||
formError.value = {};
|
||||
busy.value = true;
|
||||
|
||||
const backupConfig = {
|
||||
provider: provider.value,
|
||||
};
|
||||
|
||||
if (providerConfig.value.encryptionPassword) {
|
||||
backupConfig.password = providerConfig.value.encryptionPassword;
|
||||
backupConfig.encryptedFilenames = providerConfig.value.encryptedFilenames;
|
||||
}
|
||||
|
||||
const format = providerConfig.value.format;
|
||||
let backupId = remotePath.value;
|
||||
let backupPath = remotePath.value;
|
||||
const backupConfig = {};
|
||||
|
||||
// only set provider specific fields, this will clear them in the db
|
||||
if (s3like(provider.value)) {
|
||||
@@ -105,19 +96,23 @@ async function onSubmit() {
|
||||
backupConfig.mountPoint = providerConfig.value.mountPoint;
|
||||
} else if (provider.value === 'filesystem') {
|
||||
const parts = remotePath.value.split('/');
|
||||
backupId = parts.pop() || parts.pop(); // removes any trailing slash. this is basename()
|
||||
backupConfig.backupFolder = parts.join('/'); // this is dirname()
|
||||
backupPath = parts.pop() || parts.pop(); // removes any trailing slash. this is basename()
|
||||
backupConfig.backupDir = parts.join('/'); // this is dirname()
|
||||
}
|
||||
|
||||
if (format === 'tgz') {
|
||||
if (backupId.substring(backupId.length - '.tar.gz'.length, backupId.length) === '.tar.gz') { // endsWith
|
||||
backupId = backupId.replace(/.tar.gz$/, '');
|
||||
} else if (backupId.substring(backupId.length - '.tar.gz.enc'.length, backupId.length) === '.tar.gz.enc') { // endsWith
|
||||
backupId = backupId.replace(/.tar.gz.enc$/, '');
|
||||
}
|
||||
const data = {
|
||||
format: format.value,
|
||||
provider: provider.value,
|
||||
config: backupConfig,
|
||||
remotePath: backupPath
|
||||
};
|
||||
|
||||
if (providerConfig.value.encryptionPassword) {
|
||||
data.encryptionPassword = providerConfig.value.encryptionPassword;
|
||||
data.encryptedFilenames = providerConfig.value.encryptedFilenames;
|
||||
}
|
||||
|
||||
const [error] = await appsModel.import(appId.value, backupId, format, backupConfig);
|
||||
const [error] = await appsModel.import(appId.value, data);
|
||||
if (error) {
|
||||
busy.value = false;
|
||||
formError.value = {};
|
||||
@@ -144,7 +139,7 @@ async function onSubmit() {
|
||||
formError.value.generic = error.body.message;
|
||||
|
||||
if (provider.value === 'filesystem') {
|
||||
formError.value.backupFolder = true;
|
||||
formError.value.backupDir = true;
|
||||
}
|
||||
} else {
|
||||
formError.value.generic = 'Internal error';
|
||||
@@ -171,7 +166,7 @@ function onBackupConfigChanged(event) {
|
||||
try {
|
||||
data = JSON.parse(result.target.result); // 'provider', 'config', 'limits', 'format', 'remotePath', 'encrypted', 'encryptedFilenames'
|
||||
if (data.provider === 'filesystem') { // this allows a user to upload a backup to server and import easily with an absolute path
|
||||
data.remotePath = `${data.config.backupFolder}/${data.remotePath}`;
|
||||
data.remotePath = `${data.config.backupDir}/${data.remotePath}`;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Unable to parse backup config', e);
|
||||
|
||||
Reference in New Issue
Block a user