df: check if path exists

This commit is contained in:
Girish Ramakrishnan
2025-12-08 18:57:35 +01:00
parent cfb2501576
commit 2f40eeb49f
+2
View File
@@ -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}`);