fix(storage): release a deleted journey's photos and a deleted list's images, and keep one bad key from stopping a category

Deleting a journey left its uploaded photos behind for good, and deleting
a list queued neither its cover nor its place images. An object with a key
the store refuses no longer fails every night's pass, and the admin view
keeps the counts of a category skipped for a running backup.
This commit is contained in:
Maurice
2026-11-05 13:02:26 +01:00
parent 402a02a302
commit 9dd58fe32f
26 changed files with 350 additions and 17 deletions
@@ -14,6 +14,7 @@ import { DatabaseLifecycle } from '../database/database-lifecycle.service';
import { withRequestContext } from '../database/request-context';
import { StorageInstallService } from './storage-install.service';
import { StorageJobsService } from './storage-jobs.service';
import { isValidKey } from './storage-keys';
import { StorageReclaimGuardService } from './storage-reclaim-guard.service';
import { StorageReclaimRegistryService } from './storage-reclaim-registry.service';
import { inReclaimScope, RECLAIM_LEDGER, reclaimableCategories, sharedLocationsOf } from './storage-reclaim.ledger';
@@ -435,7 +436,10 @@ export class StorageReclaimService implements OnModuleInit {
for await (const stat of this.storage.list(category, '', { shallow: true })) {
seen += 1;
if (seen % LIST_CHECK_EVERY === 0) this.assertSameDatabase(ctx);
if (!inReclaimScope(stat.key)) continue;
// A name the storage layer refuses (a backslash or a control character in a
// local file put there by hand) can never be stat'ed or deleted: judging it
// would fail its whole delete batch every night, so it is left alone.
if (!inReclaimScope(stat.key) || !isValidKey(stat.key)) continue;
const owner = storageOwnerMarkerInstall(stat.key);
if (owner !== null) {
owners.add(owner);
@@ -78,7 +78,9 @@ class ReleaseStopped extends Error {}
/**
* What a user's change left unnamed: a replaced or removed cover, place image
* or avatar, a deleted journey photo or trip file. The owner hands the values
* or avatar, a deleted journey photo or trip file, and what a deleted list
* (its cover and saved places' images) or journey (its gallery's photos) held;
* a deleted trip hands on only its cover. The owner hands the values
* its rows held to `releaseValues` once its transaction committed, and every
* object they name is queued, which is all the request pays. Nothing goes
* before RELEASE_DELAY_MS, so an undo or a late write that brings the value