diff --git a/dashboard/src/components/DiskUsage.vue b/dashboard/src/components/DiskUsage.vue index ff7dd6d77..39f3bd49f 100644 --- a/dashboard/src/components/DiskUsage.vue +++ b/dashboard/src/components/DiskUsage.vue @@ -14,7 +14,7 @@ onMounted(async () => { const [error, result] = await systemModel.filesystems(); if (error) return console.error(error); - filesystems.value = Object.values(result); + filesystems.value = result; ready.value = true; }); diff --git a/src/system.js b/src/system.js index 14246860d..c7858c8e5 100644 --- a/src/system.js +++ b/src/system.js @@ -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); } diff --git a/src/test/system-test.js b/src/test/system-test.js index f9124ef0e..dda38139e 100644 --- a/src/test/system-test.js +++ b/src/test/system-test.js @@ -26,7 +26,7 @@ describe('System', function () { const filesystems = await system.getFilesystems(); expect(filesystems).to.be.ok(); - expect(Object.keys(filesystems).some(fs => filesystems[fs].mountpoint === '/')).to.be.ok(); + expect(filesystems.some(fs => fs.mountpoint === '/')).to.be(true); }); it('can get swaps', async function () {