admin/fs: excluding some bad entries from "disk spaces"

Massimo Melina committed May 28, 2024 at 16:16 UTC 4c95f72080e4b91eae93741bb5199b90fc201c88
1 file changed +3 -1
src/util-os.ts
+3 -1
@@ -36,7 +36,7 @@ export async function getDiskSpaces(): Promise<{ name: string, free: number, tot
36 description: x.Description
37 }))
38 }
39 - const { stdout } = await promisify(exec)(`df -k -l`).catch(err => {
39 + const { stdout } = await promisify(exec)(`df -k`).catch(err => {
40 throw err.status === 1 ? Error('miss')
41 : err.status === 127 ? Error('unsupported')
42 : err
@@ -46,7 +46,9 @@ export async function getDiskSpaces(): Promise<{ name: string, free: number, tot
46 throw Error('unsupported')
47 return onlyTruthy(out.map(one => {
48 const bits = one.split(/\s+/)
49 + if (bits[0] === 'tempfs') return
50 const name = bits.pop() || bits.shift() || ''
51 + if (/^\/(dev|System)\b/.test(name)) return
52 const [, used=0, free=0] = bits.map(x => Number(x) * 1024)
53 const total = used + free
54 return total && { free, total, name }