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

@@ -169,6 +169,7 @@ async function restoreTask(backupConfig, remotePath, ipv4Config, options, auditS
try {
setProgress('restore', 'Downloading box backup');
backupConfig.rootPath = backups.getRootPath(backupConfig, paths.MANAGED_BACKUP_MOUNT_DIR);
await backuptask.restore(backupConfig, remotePath, (progress) => setProgress('restore', progress.message));
setProgress('restore', 'Downloading mail backup');
@@ -231,8 +232,7 @@ async function restore(backupConfig, remotePath, version, ipv4Config, options, a
}
await backups.setupStorage(backupConfig, paths.MANAGED_BACKUP_MOUNT_DIR); // this validates mountOptions
backupConfig.rootPath = backups.getRootPath(backupConfig, paths.MANAGED_BACKUP_MOUNT_DIR);
error = await backups.testStorage(backupConfig); // this validates provider and it's api options. requires rootPath
error = await backups.testStorage(Object.assign({ mountPath: paths.MANAGED_BACKUP_MOUNT_DIR }), backupConfig); // this validates provider and it's api options. requires mountPath
if (error) throw error;
error = await network.testIPv4Config(ipv4Config);