du: better error handling of du
du can fail when files and directories go missing. luckily, when du fails, it still provides the best effort output
This commit is contained in:
@@ -40,10 +40,10 @@ const assert = require('assert'),
|
||||
safe = require('safetydance'),
|
||||
shell = require('../shell.js')('filesystem');
|
||||
|
||||
// the du call in the function below requires root
|
||||
async function getAvailableSize(apiConfig) {
|
||||
assert.strictEqual(typeof apiConfig, 'object');
|
||||
|
||||
// note that df returns the disk size (as opposed to the apparent size)
|
||||
const [error, dfResult] = await safe(df.file(apiConfig.rootPath));
|
||||
if (error) throw new BoxError(BoxError.FS_ERROR, `Error when checking for disk space: ${error.message}`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user