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

@@ -461,7 +461,7 @@ async function setupStorage(storageConfig, hostPath) {
const newMount = {
name: path.basename(hostPath),
hostPath: hostPath,
hostPath,
mountType: storageConfig.provider,
mountOptions: storageConfig.mountOptions
};
@@ -496,8 +496,7 @@ async function setStorage(storageConfig) {
debug('setStorage: validating new storage configuration');
const testMountObject = await setupStorage(storageConfig, '/mnt/backup-storage-validation'); // this validates mountOptions
const rootPath = getRootPath(storageConfig, '/mnt/backup-storage-validation');
const testStorageError = await testStorage(Object.assign({ rootPath }, storageConfig)); // this validates provider and it's api options. requires rootPath
const testStorageError = await testStorage(Object.assign({ mountPath: '/mnt/backup-storage-validation' }, storageConfig)); // this validates provider and it's api options. requires mountPath
if (testMountObject) await mounts.removeMount(testMountObject);
if (testStorageError) throw testStorageError;