diff --git a/src/apps.js b/src/apps.js index f29e56bad..c6bd83a9f 100644 --- a/src/apps.js +++ b/src/apps.js @@ -2235,11 +2235,6 @@ async function importApp(app, data, auditSource) { error = backups.validateFormat(backupFormat); if (error) throw error; - await backups.setupStorage(backupConfig, `/mnt/appimport-${app.id}`); - backupConfig.rootPath = backups.getRootPath(backupConfig, `/mnt/appimport-${app.id}`); - error = await backups.testStorage(backupConfig); - if (error) throw error; - if ('password' in backupConfig) { backupConfig.encryption = backups.generateEncryptionKeysSync(backupConfig.password); delete backupConfig.password; @@ -2247,6 +2242,11 @@ async function importApp(app, data, auditSource) { backupConfig.encryption = null; } + await backups.setupStorage(backupConfig, `/mnt/appimport-${app.id}`); // this validates mountOptions + backupConfig.rootPath = backups.getRootPath(backupConfig, `/mnt/appimport-${app.id}`); + error = await backups.testStorage(backupConfig); // this validates provider and it's api options. requires rootPath + if (error) throw error; + restoreConfig = { remotePath, backupFormat, backupConfig }; } else { restoreConfig = { remotePath: null }; diff --git a/src/routes/apps.js b/src/routes/apps.js index 5f2889ce1..df646db90 100644 --- a/src/routes/apps.js +++ b/src/routes/apps.js @@ -540,7 +540,6 @@ async function importApp(req, res, next) { if (typeof backupConfig.provider !== 'string') return next(new HttpError(400, 'provider is required')); if ('password' in backupConfig && typeof backupConfig.password !== 'string') return next(new HttpError(400, 'password must be a string')); if ('encryptedFilenames' in backupConfig && typeof backupConfig.encryptedFilenames !== 'boolean') return next(new HttpError(400, 'encryptedFilenames must be a boolean')); - if ('acceptSelfSignedCerts' in backupConfig && typeof backupConfig.acceptSelfSignedCerts !== 'boolean') return next(new HttpError(400, 'format must be a boolean')); // testing backup config can take sometime req.clearTimeout();