shell: rename signal to abortSignal
this prevents accidental typos with child_process signal handling
This commit is contained in:
+7
-7
@@ -44,7 +44,7 @@ async function du(file, options) {
|
||||
assert.strictEqual(typeof file, 'string');
|
||||
assert.strictEqual(typeof options, 'object');
|
||||
|
||||
const [error, stdoutResult] = await safe(shell.sudo([ DU_CMD, file ], { encoding: 'utf8', signal: options.signal }));
|
||||
const [error, stdoutResult] = await safe(shell.sudo([ DU_CMD, file ], { encoding: 'utf8', abortSignal: options.abortSignal }));
|
||||
if (error) throw new BoxError(BoxError.FS_ERROR, error);
|
||||
|
||||
return parseInt(stdoutResult.trim(), 10);
|
||||
@@ -54,7 +54,7 @@ async function hdparm(file, options) {
|
||||
assert.strictEqual(typeof file, 'string');
|
||||
assert.strictEqual(typeof options, 'object');
|
||||
|
||||
const [error, stdoutResult] = await safe(shell.sudo([ HDPARM_CMD, file ], { encoding: 'utf8', signal: options.signal }));
|
||||
const [error, stdoutResult] = await safe(shell.sudo([ HDPARM_CMD, file ], { encoding: 'utf8', abortSignal: options.abortSignal }));
|
||||
if (error) throw new BoxError(BoxError.FS_ERROR, error);
|
||||
|
||||
const lines = stdoutResult.split('\n');
|
||||
@@ -226,25 +226,25 @@ class FilesystemUsageTask extends AsyncTask {
|
||||
this.#filesystem = filesystem;
|
||||
}
|
||||
|
||||
async _run(signal) {
|
||||
async _run(abortSignal) {
|
||||
const { filesystem, type, contents } = this.#filesystem;
|
||||
|
||||
let percent = 5;
|
||||
|
||||
if (type === 'ext4' || type === 'xfs') { // hdparm only works with block devices
|
||||
this.emitProgress(percent, 'Calculating Disk Speed');
|
||||
const [speedError, speed] = await safe(hdparm(filesystem, { signal }));
|
||||
const [speedError, speed] = await safe(hdparm(filesystem, { abortSignal }));
|
||||
if (speedError) debug(`hdparm error ${filesystem}: ${speedError.message}`);
|
||||
this.emitData({ speed: speedError ? -1 : speed });
|
||||
} else {
|
||||
this.emitData({ speed: -1 });
|
||||
}
|
||||
|
||||
const dockerDf = await docker.df({ abortSignal: signal });
|
||||
const dockerDf = await docker.df({ abortSignal });
|
||||
|
||||
for (const content of contents) {
|
||||
percent += (90/contents.length+1);
|
||||
if (signal.aborted) return;
|
||||
if (abortSignal.aborted) return;
|
||||
|
||||
this.emitProgress(percent,`Checking du of ${content.id} ${content.path}`);
|
||||
if (content.id === 'docker') {
|
||||
@@ -252,7 +252,7 @@ class FilesystemUsageTask extends AsyncTask {
|
||||
} else if (content.id === 'docker-volumes') {
|
||||
content.usage = dockerDf.Volumes.map((v) => v.UsageData.Size).reduce((a,b) => a + b, 0);
|
||||
} else {
|
||||
const [error, usage] = await safe(du(content.path, { signal }));
|
||||
const [error, usage] = await safe(du(content.path, { abortSignal }));
|
||||
if (error) debug(`du error ${content.path}: ${error.message}`); // can happen if app is installing etc
|
||||
content.usage = usage || 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user