add system.du

This commit is contained in:
Girish Ramakrishnan
2022-10-11 22:58:12 +02:00
parent 760301ce02
commit 656f3fcc13
6 changed files with 54 additions and 4 deletions

View File

@@ -4,7 +4,8 @@ exports = module.exports = {
getDisks,
checkDiskSpace,
getMemory,
getMemoryAllocation
getMemoryAllocation,
du
};
const apps = require('./apps.js'),
@@ -16,11 +17,22 @@ const apps = require('./apps.js'),
docker = require('./docker.js'),
notifications = require('./notifications.js'),
os = require('os'),
path = require('path'),
paths = require('./paths.js'),
safe = require('safetydance'),
settings = require('./settings.js'),
shell = require('./shell.js'),
volumes = require('./volumes.js');
const DU_CMD = path.join(__dirname, 'scripts/du.sh');
async function du(file) {
const [error, stdoutResult] = await safe(shell.promises.sudo('system', [ DU_CMD, file ], {}));
if (error) throw new BoxError(BoxError.FS_ERROR, error);
return parseInt(stdoutResult.trim(), 10);
}
async function getVolumeDisks(appsDataDisk) {
assert.strictEqual(typeof appsDataDisk, 'string');