import: make the ui work again

This commit is contained in:
Girish Ramakrishnan
2025-07-28 11:45:10 +02:00
parent 89388940ed
commit 373ef5b7e1
6 changed files with 64 additions and 62 deletions

View File

@@ -2352,31 +2352,31 @@ async function importApp(app, data, auditSource) {
const appId = app.id;
const { remotePath, backupFormat, backupConfig } = data;
const { remotePath, format, encryptionPassword, encryptedFilenames, config } = data;
let error = checkAppState(app, exports.ISTATE_PENDING_IMPORT);
if (error) throw error;
let restoreConfig;
let encryption, restoreConfig;
if (data.remotePath) { // if not provided, we import in-place
error = backupTargets.validateFormat(backupFormat);
error = backupTargets.validateFormat(format);
if (error) throw error;
if ('password' in backupConfig) {
backupConfig.encryption = hush.generateEncryptionKeysSync(backupConfig.password);
delete backupConfig.password;
if (encryptionPassword) {
encryption = hush.generateEncryptionKeysSync(encryptionPassword);
encryption.encryptedFilenames = !!encryptedFilenames;
} else {
backupConfig.encryption = null;
encryption = null;
}
await backupTargets.setupManagedStorage(backupConfig, `/mnt/appimport-${app.id}`); // this validates mountOptions . this is not cleaned up, it's fine
backupConfig.rootPath = backupTargets.getRootPath(backupConfig, `/mnt/appimport-${app.id}`);
error = await backupTargets.testStorage(Object.assign({ mountPath: `/mnt/appimport-${app.id}` }, backupConfig)); // this validates provider and it's api options. requires mountPath
await backupTargets.setupManagedStorage(config, `/mnt/appimport-${app.id}`); // this validates mountOptions . this is not cleaned up, it's fine
config.rootPath = backupTargets.getRootPath(config, `/mnt/appimport-${app.id}`);
error = await backupTargets.testStorage(Object.assign({ mountPath: `/mnt/appimport-${app.id}` }, config)); // this validates provider and it's api options. requires mountPath
if (error) throw error;
restoreConfig = { remotePath, backupFormat, backupConfig };
} else {
restoreConfig = { remotePath, backupFormat: format, backupConfig: config };
} else { // inPlace
restoreConfig = { remotePath: null };
}