data dir: allow sameness of old and new dir

this makes it easy to migrate to a new volume setup
This commit is contained in:
Girish Ramakrishnan
2022-06-09 17:49:33 -07:00
parent f382b8f1f5
commit a32166bc9d
3 changed files with 25 additions and 6 deletions

View File

@@ -512,7 +512,7 @@ async function checkStorage(app, volumeId, prefix) {
const rel = path.relative(sourceDir, targetDir);
if (!rel.startsWith('../') && rel.split('/').length > 1) throw new BoxError(BoxError.BAD_FIELD, 'Only one level subdirectory moves are supported');
const [error] = await safe(shell.promises.sudo('checkStorage', [ CHECKVOLUME_CMD, targetDir ], {}));
const [error] = await safe(shell.promises.sudo('checkStorage', [ CHECKVOLUME_CMD, targetDir, sourceDir ], {}));
if (error && error.code === 2) throw new BoxError(BoxError.BAD_FIELD, `Target directory ${targetDir} is not empty`);
if (error && error.code === 3) throw new BoxError(BoxError.BAD_FIELD, `Target directory ${targetDir} does not support chown`);