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
+11 -12
View File
@@ -575,22 +575,21 @@ async function importApp(req, res, next) {
const data = req.body;
if ('remotePath' in data) { // if not provided, we import in-place
if ('remotePath' in data) {
if (typeof data.remotePath !== 'string' || !data.remotePath) return next(new HttpError(400, 'remotePath must be non-empty string'));
if (typeof data.backupFormat !== 'string') return next(new HttpError(400, 'backupFormat must be string'));
if (typeof data.format !== 'string') return next(new HttpError(400, 'format must be string'));
if (typeof config.provider !== 'string') return next(new HttpError(400, 'provider is required'));
if (typeof data.config !== 'object' || !data.config) return next(new HttpError(400, 'config must be an object'));
if ('backupConfig' in data && typeof data.backupConfig !== 'object') return next(new HttpError(400, 'backupConfig must be an object'));
const config = req.body.config;
const backupConfig = req.body.backupConfig;
if ('encryptionPassword' in config && typeof config.encryptionPassword !== 'string') return next(new HttpError(400, 'encryptionPassword must be a string'));
if ('encryptedFilenames' in config && typeof config.encryptedFilenames !== 'boolean') return next(new HttpError(400, 'encryptedFilenames must be a boolean'));
if (backupConfig) {
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'));
// testing backup config can take sometime
req.clearTimeout();
}
// testing backup config can take sometime
req.clearTimeout();
} else {
if (typeof data.inPlace !== 'boolean') return next(new HttpError(400, 'remotePath or inPlace is required'));
}
const [error, result] = await safe(apps.importApp(req.resources.app, data, AuditSource.fromRequest(req)));