system: make filesystem return value an array

Filesystem of df output is not unique
This commit is contained in:
Girish Ramakrishnan
2025-07-20 09:59:51 +02:00
parent 1e8df5c9d0
commit 66107cf7a4
3 changed files with 6 additions and 7 deletions
+4 -5
View File
@@ -174,7 +174,7 @@ async function getFilesystems() {
filesystems[dfResult?.filesystem || rootDisk.filesystem].contents.push({ type: 'swap', id: swap.name, path: swap.name });
}
return filesystems;
return Object.values(filesystems);
}
async function checkDiskSpace() {
@@ -184,8 +184,7 @@ async function checkDiskSpace() {
let markdownMessage = '';
for (const fsPath in filesystems) {
const filesystem = filesystems[fsPath];
for (const filesystem of filesystems) {
if (filesystem.contents.length === 0) continue; // ignore if nothing interesting here
if (filesystem.capacity >= 0.90) { // > 90%
@@ -267,9 +266,9 @@ async function getFilesystemUsage(fsPath) {
assert.strictEqual(typeof fsPath, 'string');
const filesystems = await getFilesystems();
if (!(fsPath in filesystems)) throw new BoxError(BoxError.BAD_FIELD, 'No such filesystem');
const filesystem = filesystems.find(f => f.filesystem === fsPath);
if (!filesystem) throw new BoxError(BoxError.BAD_FIELD, 'No such filesystem');
const filesystem = filesystems[fsPath];
return new FilesystemUsageTask(filesystem);
}