filesystem: rename backupFolder to backupDir
This commit is contained in:
@@ -47,7 +47,7 @@ function getRootPath(config) {
|
||||
} else if (config._provider === mounts.MOUNT_TYPE_MOUNTPOINT) {
|
||||
return path.join(config.mountPoint, prefix);
|
||||
} else if (config._provider === mounts.MOUNT_TYPE_FILESYSTEM) {
|
||||
return path.join(config.backupFolder, prefix);
|
||||
return path.join(config.backupDir, prefix);
|
||||
}
|
||||
|
||||
throw new BoxError(BoxError.INTERNAL_ERROR, `Unhandled provider: ${config._provider}`);
|
||||
@@ -239,15 +239,15 @@ async function removeDir(config, remotePathPrefix, progressCallback) {
|
||||
function validateDestDir(dir) {
|
||||
assert.strictEqual(typeof dir, 'string');
|
||||
|
||||
if (path.normalize(dir) !== dir) return new BoxError(BoxError.BAD_FIELD, 'backupFolder/mountpoint must contain a normalized path');
|
||||
if (!path.isAbsolute(dir)) return new BoxError(BoxError.BAD_FIELD, 'backupFolder/mountpoint must be an absolute path');
|
||||
if (path.normalize(dir) !== dir) return new BoxError(BoxError.BAD_FIELD, 'backupDir/mountpoint must contain a normalized path');
|
||||
if (!path.isAbsolute(dir)) return new BoxError(BoxError.BAD_FIELD, 'backupDir/mountpoint must be an absolute path');
|
||||
|
||||
if (dir === '/') return new BoxError(BoxError.BAD_FIELD, 'backupFolder/mountpoint cannot be /');
|
||||
if (dir === '/') return new BoxError(BoxError.BAD_FIELD, 'backupDir/mountpoint cannot be /');
|
||||
|
||||
if (!dir.endsWith('/')) dir = dir + '/'; // ensure trailing slash for the prefix matching to work
|
||||
const PROTECTED_PREFIXES = [ '/boot/', '/usr/', '/bin/', '/lib/', '/root/', '/var/lib/', paths.baseDir() ];
|
||||
|
||||
if (PROTECTED_PREFIXES.some(p => dir.startsWith(p))) return new BoxError(BoxError.BAD_FIELD, 'backupFolder path is protected');
|
||||
if (PROTECTED_PREFIXES.some(p => dir.startsWith(p))) return new BoxError(BoxError.BAD_FIELD, 'backupDir path is protected');
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -318,8 +318,8 @@ async function verifyConfig({ id, provider, config }) {
|
||||
}
|
||||
|
||||
if (provider === mounts.MOUNT_TYPE_FILESYSTEM) {
|
||||
if (!config.backupFolder || typeof config.backupFolder !== 'string') throw new BoxError(BoxError.BAD_FIELD, 'backupFolder must be non-empty string');
|
||||
const error = validateDestDir(config.backupFolder);
|
||||
if (!config.backupDir || typeof config.backupDir !== 'string') throw new BoxError(BoxError.BAD_FIELD, 'backupDir must be non-empty string');
|
||||
const error = validateDestDir(config.backupDir);
|
||||
if (error) throw error;
|
||||
} else {
|
||||
if (mounts.isManagedProvider(provider)) {
|
||||
@@ -341,7 +341,7 @@ async function verifyConfig({ id, provider, config }) {
|
||||
}
|
||||
}
|
||||
|
||||
const tmp = _.pick(config, ['noHardlinks', 'chown', 'preserveAttributes', 'backupFolder', 'prefix', 'mountOptions', 'mountPoint']);
|
||||
const tmp = _.pick(config, ['noHardlinks', 'chown', 'preserveAttributes', 'backupDir', 'prefix', 'mountOptions', 'mountPoint']);
|
||||
const newConfig = { _provider: provider, _managedMountPath: managedMountPath, ...tmp };
|
||||
const fullPath = getRootPath(newConfig);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user