system: make filesystem return value an array
Filesystem of df output is not unique
This commit is contained in:
+4
-5
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user