show total disk usage for each app

This commit is contained in:
Chris Wanstrath 2026-02-14 08:06:30 -08:00
parent 6afefcec5b
commit 65e19d27e2

View File

@ -13,6 +13,7 @@ const DATA_HISTORY_MAX_DAYS = 30 // Keep 30 days of data size history
const SAMPLE_INTERVAL_MS = 10_000 // How often to sample process metrics
const HISTORY_MAX_SAMPLES = 60 // Keep 10 minutes of history at 10s intervals
const APPS_DIR = process.env.APPS_DIR!
const TOES_DIR = process.env.TOES_DIR!
const TOES_URL = process.env.TOES_URL!
@ -178,9 +179,12 @@ setInterval(sampleAndRecordHistory, SAMPLE_INTERVAL_MS)
// ============================================================================
function getDataSize(appName: string): number {
let total = 0
const appDir = join(APPS_DIR, appName)
if (existsSync(appDir)) total += dirSize(appDir)
const dataDir = join(TOES_DIR, appName)
if (!existsSync(dataDir)) return 0
return dirSize(dataDir)
if (existsSync(dataDir)) total += dirSize(dataDir)
return total
}
function dirSize(dir: string): number {