diff --git a/migrations/20220626163116-backupConfig-default-encryptFilenames.js b/migrations/20220626163116-backupConfig-default-encryptedFilenames.js similarity index 78% rename from migrations/20220626163116-backupConfig-default-encryptFilenames.js rename to migrations/20220626163116-backupConfig-default-encryptedFilenames.js index 1eed85606..c7dad27ca 100644 --- a/migrations/20220626163116-backupConfig-default-encryptFilenames.js +++ b/migrations/20220626163116-backupConfig-default-encryptedFilenames.js @@ -6,7 +6,7 @@ exports.up = async function(db) { const backupConfig = JSON.parse(result[0].value); - if (backupConfig.encryption) backupConfig.encryptFilenames = true; + if (backupConfig.encryption && backupConfig.format === 'rsync') backupConfig.encryptedFilenames = true; await db.runSql('UPDATE settings SET value=? WHERE name=?', [ JSON.stringify(backupConfig), 'backup_config', ]); }; diff --git a/src/backupformat/rsync.js b/src/backupformat/rsync.js index b40664c3f..cd3ae4f76 100644 --- a/src/backupformat/rsync.js +++ b/src/backupformat/rsync.js @@ -46,7 +46,7 @@ function sync(backupConfig, remotePath, dataLayout, progressCallback, callback) syncer.sync(dataLayout, function processTask(task, iteratorCallback) { debug('sync: processing task: %j', task); // the empty task.path is special to signify the directory - const destPath = task.path && backupConfig.encryptFilenames ? hush.encryptFilePath(task.path, backupConfig.encryption) : task.path; + const destPath = task.path && backupConfig.encryptedFilenames ? hush.encryptFilePath(task.path, backupConfig.encryption) : task.path; const backupFilePath = path.join(getBackupFilePath(backupConfig, remotePath), destPath); if (task.operation === 'removedir') { @@ -164,7 +164,7 @@ function downloadDir(backupConfig, backupFilePath, dataLayout, progressCallback, function downloadFile(entry, done) { let relativePath = path.relative(backupFilePath, entry.fullPath); - if (backupConfig.encryptFilenames) { + if (backupConfig.encryptedFilenames) { const { error, result } = hush.decryptFilePath(relativePath, backupConfig.encryption); if (error) return done(new BoxError(BoxError.CRYPTO_ERROR, 'Unable to decrypt file')); relativePath = result; diff --git a/src/routes/apps.js b/src/routes/apps.js index 30d2d7762..b950cbb72 100644 --- a/src/routes/apps.js +++ b/src/routes/apps.js @@ -508,6 +508,7 @@ async function importApp(req, res, next) { if (req.body.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')); if ('acceptSelfSignedCerts' in backupConfig && typeof backupConfig.acceptSelfSignedCerts !== 'boolean') return next(new HttpError(400, 'format must be a boolean')); // testing backup config can take sometime diff --git a/src/routes/provision.js b/src/routes/provision.js index dee869d08..a13430069 100644 --- a/src/routes/provision.js +++ b/src/routes/provision.js @@ -103,6 +103,8 @@ async function restore(req, res, next) { const backupConfig = req.body.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 req.body && typeof req.body.encryptedFilenames !== 'boolean') return next(new HttpError(400, 'encryptedFilenames must be a boolean')); + if (typeof backupConfig.format !== 'string') return next(new HttpError(400, 'format must be a string')); if ('acceptSelfSignedCerts' in backupConfig && typeof backupConfig.acceptSelfSignedCerts !== 'boolean') return next(new HttpError(400, 'format must be a boolean')); diff --git a/src/routes/settings.js b/src/routes/settings.js index c5e26cc27..80e4ff5ea 100644 --- a/src/routes/settings.js +++ b/src/routes/settings.js @@ -73,10 +73,8 @@ async function setBackupConfig(req, res, next) { if (typeof req.body.provider !== 'string') return next(new HttpError(400, 'provider is required')); if (typeof req.body.schedulePattern !== 'string') return next(new HttpError(400, 'schedulePattern is required')); - if ('password' in req.body) { - if (typeof req.body.password !== 'string') return next(new HttpError(400, 'password must be a string')); - if (typeof req.body.encryptFilenames !== 'boolean') return next(new HttpError(400, 'encryptFilenames must be a boolean')); - } + if ('password' in req.body && typeof req.body.password !== 'string') return next(new HttpError(400, 'password must be a string')); + if ('encryptedFilenames' in req.body && typeof req.body.encryptedFilenames !== 'boolean') return next(new HttpError(400, 'encryptedFilenames must be a boolean')); if ('syncConcurrency' in req.body) { if (typeof req.body.syncConcurrency !== 'number') return next(new HttpError(400, 'syncConcurrency must be a positive integer')); diff --git a/src/settings.js b/src/settings.js index 0ae4a193a..32431b83c 100644 --- a/src/settings.js +++ b/src/settings.js @@ -455,7 +455,7 @@ async function setBackupConfig(backupConfig) { } // if any of these changes, we have to clear the cache - if ([ 'format', 'provider', 'prefix', 'bucket', 'region', 'endpoint', 'backupFolder', 'mountPoint', 'encryption', 'encryptFilenames' ].some(p => backupConfig[p] !== oldConfig[p])) { + if ([ 'format', 'provider', 'prefix', 'bucket', 'region', 'endpoint', 'backupFolder', 'mountPoint', 'encryption', 'encryptedFilenames' ].some(p => backupConfig[p] !== oldConfig[p])) { debug('setBackupConfig: clearing backup cache'); backups.cleanupCacheFilesSync(); }