diff --git a/src/df.js b/src/df.js index 309102a88..45a06cd45 100644 --- a/src/df.js +++ b/src/df.js @@ -54,6 +54,8 @@ async function filesystems() { async function file(filename) { assert.strictEqual(typeof filename, 'string'); + if (!safe.fs.existsSync(filename)) throw new BoxError(BoxError.NOT_FOUND, `Path ${filename} does not exist`); + const [error, output] = await safe(shell.spawn('df', ['-B1', '--output=source,fstype,size,used,avail,pcent,target', filename], { encoding: 'utf8', timeout: 5000 })); if (error) { debug(`file: df command failed. error: ${error}\n stdout: ${error.stdout}\n stderr: ${error.stderr}`);