From 6d75115a38727276e06aceecf8712d631fb46b26 Mon Sep 17 00:00:00 2001 From: Namekuji Date: Wed, 21 Jun 2023 16:26:43 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20empty=20fs=20stat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/server/api/endpoints/server-info.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/server-info.ts b/packages/backend/src/server/api/endpoints/server-info.ts index cc9aa91b2..81bb053db 100644 --- a/packages/backend/src/server/api/endpoints/server-info.ts +++ b/packages/backend/src/server/api/endpoints/server-info.ts @@ -1,7 +1,7 @@ import * as os from "node:os"; import si from "systeminformation"; import define from "../define.js"; -import meilisearch from "../../../db/meilisearch.js"; +import meilisearch from "@/db/meilisearch.js"; export const meta = { requireCredential: false, @@ -19,7 +19,15 @@ export const paramDef = { export default define(meta, paramDef, async () => { const memStats = await si.mem(); const fsStats = await si.fsSize(); - const meilisearchStats = await meilisearchStatus(); + + let fsIndex = 0; + // Get the first index of fs sizes that are actualy used. + for (const [i, stat] of fsStats.entries()) { + if (stat.rw === true && stat.used > 0) { + fsIndex = i; + break; + } + } return { machine: os.hostname(), @@ -31,8 +39,8 @@ export default define(meta, paramDef, async () => { total: memStats.total, }, fs: { - total: fsStats[0].size, - used: fsStats[0].used, + total: fsStats[fsIndex].size, + used: fsStats[fsIndex].used, }, }; });