backup/import/restore: fix crash with root path calcuation

rootPath was calculated before the arguments were validated
This commit is contained in:
Girish Ramakrishnan
2024-04-09 13:53:15 +02:00
parent 5460a64951
commit 2b1b304c6e
4 changed files with 20 additions and 18 deletions

View File

@@ -2242,9 +2242,9 @@ async function importApp(app, data, auditSource) {
backupConfig.encryption = null;
}
await backups.setupStorage(backupConfig, `/mnt/appimport-${app.id}`); // this validates mountOptions
await backups.setupStorage(backupConfig, `/mnt/appimport-${app.id}`); // this validates mountOptions . this is not cleaned up, it's fine
backupConfig.rootPath = backups.getRootPath(backupConfig, `/mnt/appimport-${app.id}`);
error = await backups.testStorage(backupConfig); // this validates provider and it's api options. requires rootPath
error = await backups.testStorage(Object.assign({ mountPath: `/mnt/appimport-${app.id}` }, backupConfig)); // this validates provider and it's api options. requires mountPath
if (error) throw error;
restoreConfig = { remotePath, backupFormat, backupConfig };