Add media storage limits, retention, and the near-limit flow

This commit is contained in:
Fisto
2026-09-16 08:49:42 +02:00
parent 6b961ddcef
commit 8f3f153c55
15 changed files with 394 additions and 12 deletions
+13
View File
@@ -216,6 +216,19 @@ export class ScrapeStore {
return added;
}
/** Sum of the recorded source sizes per kind. Used by the storage bar. */
sumBytesByKind(): Record<MediaKind, number> {
const rows = this.db
.prepare("SELECT kind, COALESCE(SUM(size), 0) AS bytes FROM media GROUP BY kind")
.all() as unknown as Array<{ kind: string; bytes: number }>;
const result = emptyMediaCounts();
for (const row of rows) {
if (row.kind in result) result[row.kind as MediaKind] = row.bytes;
}
return result;
}
counts(): Record<MediaKind, number> {
const rows = this.db
.prepare("SELECT kind, COUNT(*) AS n FROM media GROUP BY kind")