The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix(storage): type the key search run, split the reclaim view per category
Maurice59a6d92ceaf1
diff --git a/client/src/components/Admin/storage/reclaimModel.ts b/client/src/components/Admin/storage/reclaimModel.tsindex 02314bcff..e686711b1 100644--- a/client/src/components/Admin/storage/reclaimModel.ts+++ b/client/src/components/Admin/storage/reclaimModel.ts@@ -65,6 +65,36 @@ function freedBy(run: StorageReclaimReport | null): ReclaimCount {);}+/**+ * The reclaim state as the storage panels show it, desktop and phone alike.+ * `null` (a server from before the reclaim pass, or a state not loaded) reads+ * as deletion off, not running and never checked.+ */+/**+ * One category of the last check as a line, or null when it has nothing to+ * say. A category the pass stopped in still counts what it found; one it+ * never judged counts nothing.+ */+function lineOf(+ category: ReclaimCategoryLine['category'],+ report: StorageReclaimCategoryReport | undefined+): ReclaimCategoryLine | null {+ if (!report || report.skipped === 'not_reclaimed') return null;+ const judged = report.skipped === null || report.skipped === 'interrupted' || report.skipped === 'delete_failed';+ // What was deleted on this run no longer waits to be freed.+ const freeable = judged ? minus(report.eligible, report.deleted) : NONE;+ const waiting = judged ? minus(report.unreferenced, report.eligible) : NONE;+ const line = {+ category,+ freeable,+ waiting,+ confirmationRequired: report.confirmationRequired,+ skipped: report.skipped,+ };+ const quiet = freeable.objects === 0 && waiting.objects === 0 && !line.confirmationRequired && line.skipped === null;+ return quiet ? null : line;+}+/*** The reclaim state as the storage panels show it, desktop and phone alike.* `null` (a server from before the reclaim pass, or a state not loaded) reads@@ -72,32 +102,9 @@ function freedBy(run: StorageReclaimReport | null): ReclaimCount {*/export function reclaimView(state: StorageReclaimState | null): ReclaimView {const run = state?.lastRun ?? null;- const lines: ReclaimCategoryLine[] = [];- let freeable = NONE;- let waiting = NONE;- for (const category of STORAGE_RECLAIM_CATEGORIES) {- const report = run?.categories[category];- if (!report || report.skipped === 'not_reclaimed') continue;- // What was deleted on this run no longer waits to be freed.- const due = minus(report.eligible, report.deleted);- const young = minus(report.unreferenced, report.eligible);- // A category the pass stopped in, or that waits for a confirmation, still- // counts what it found; one it never judged counts nothing.- const judged = report.skipped === null || report.skipped === 'interrupted' || report.skipped === 'delete_failed';- if (judged) {- freeable = add(freeable, due);- waiting = add(waiting, young);- }- const counts = judged ? { freeable: due, waiting: young } : { freeable: NONE, waiting: NONE };- if (- counts.freeable.objects > 0 ||- counts.waiting.objects > 0 ||- report.confirmationRequired ||- report.skipped !== null- ) {- lines.push({ category, ...counts, confirmationRequired: report.confirmationRequired, skipped: report.skipped });- }- }+ const lines = STORAGE_RECLAIM_CATEGORIES.flatMap((category) => lineOf(category, run?.categories[category]) ?? []);+ const freeable = lines.reduce((sum, line) => add(sum, line.freeable), NONE);+ const waiting = lines.reduce((sum, line) => add(sum, line.waiting), NONE);const deleteRun = state?.lastDeleteRun ?? null;return {deleteEnabled: state?.deleteEnabled ?? false,diff --git a/server/src/nest/storage/storage-reclaim.types.ts b/server/src/nest/storage/storage-reclaim.types.tsindex bf71fb640..23ae2ce1e 100644--- a/server/src/nest/storage/storage-reclaim.types.ts+++ b/server/src/nest/storage/storage-reclaim.types.ts@@ -165,8 +165,8 @@ export function keysNamedIn(* when the key has no run long enough to narrow anything.*/export function keySearchCore(key: string): string | null {- const runs = key.toLowerCase().match(/[a-z0-9-]+/g) ?? [];- const longest = runs.reduce((best, run) => (run.length > best.length ? run : best), '');+ const runs: string[] = key.toLowerCase().match(/[a-z0-9-]+/g) ?? [];+ const longest = runs.reduce<string>((best, run) => (run.length > best.length ? run : best), '');return longest.length >= 8 ? longest : null;}diff --git a/server/tests/unit/nest/storage/storage-reclaim.service.test.ts b/server/tests/unit/nest/storage/storage-reclaim.service.test.tsindex 516b47619..a86a5f974 100644--- a/server/tests/unit/nest/storage/storage-reclaim.service.test.ts+++ b/server/tests/unit/nest/storage/storage-reclaim.service.test.ts@@ -708,9 +708,11 @@ describe('StorageReclaimService: a pass that stops, and a restore', () => {it('RCLS-033: a restore that begins mid-pass stops it before the delete, and waits for it to let go', async () => {await markedWeekOld(['orphan.jpg']);let restoreStarted: Promise<void> | null = null;+ let restoreAsked = false;let restoreWent = false;onAsk = (_category, keys) => {- if (keys === null || restoreStarted) return;+ if (keys === null || restoreAsked) return;+ restoreAsked = true;restoreStarted = jobs.beginRestore().then(() => {restoreWent = true;});