apptask: only move app uses localstorage addon
This commit is contained in:
@@ -510,6 +510,8 @@ async function checkStorage(app, volumeId, prefix) {
|
||||
if (prefix !== '' && path.normalize(prefix) !== prefix) throw new BoxError(BoxError.BAD_FIELD, `prefix "${prefix}" is not a normalized path`);
|
||||
|
||||
const sourceDir = await getStorageDir(app);
|
||||
if (sourceDir === null) throw new BoxError(BoxError.BAD_STATE, 'App does not use localstorage addon');
|
||||
|
||||
const targetDir = path.join(volume.hostPath, 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');
|
||||
@@ -557,6 +559,8 @@ function getDuplicateErrorDetails(errorMessage, locations, portBindings) {
|
||||
async function getStorageDir(app) {
|
||||
assert.strictEqual(typeof app, 'object');
|
||||
|
||||
if (!app.manifest.addons?.localstorage) return null;
|
||||
|
||||
if (!app.storageVolumeId) return path.join(paths.APPS_DATA_DIR, app.id, 'data');
|
||||
const volume = await volumes.get(app.storageVolumeId);
|
||||
if (!volume) throw new BoxError(BoxError.NOT_FOUND, 'Volume not found'); // not possible
|
||||
|
||||
Reference in New Issue
Block a user