shell: make require take a tag

This commit is contained in:
Girish Ramakrishnan
2024-10-14 19:10:31 +02:00
parent 02823c4158
commit a9e1d7641d
27 changed files with 162 additions and 156 deletions
+3 -3
View File
@@ -170,7 +170,7 @@ const appstore = require('./appstore.js'),
safe = require('safetydance'),
semver = require('semver'),
services = require('./services.js'),
shell = require('./shell.js'),
shell = require('./shell.js')('apps'),
storage = require('./storage.js'),
tasks = require('./tasks.js'),
tgz = require('./backupformat/tgz.js'),
@@ -518,7 +518,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, sourceDir ], {}));
const [error] = await safe(shell.promises.sudo([ 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`);
@@ -2896,7 +2896,7 @@ async function uploadFile(app, sourceFilePath, destFilePath) {
// the built-in bash printf understands "%q" but not /usr/bin/printf.
// ' gets replaced with '\'' . the first closes the quote and last one starts a new one
const escapedDestFilePath = await shell.exec('uploadFile', `printf %q '${destFilePath.replace(/'/g, '\'\\\'\'')}'`, { shell: '/bin/bash' });
const escapedDestFilePath = await shell.exec(`printf %q '${destFilePath.replace(/'/g, '\'\\\'\'')}'`, { shell: '/bin/bash' });
debug(`uploadFile: ${sourceFilePath} -> ${escapedDestFilePath}`);
const execId = await createExec(app, { cmd: [ 'bash', '-c', `cat - > ${escapedDestFilePath}` ], tty: false });