fix(storage): stop deleting covers, place images and journey photos another row may still show

Replacing a trip or list cover, changing or deleting a place or saved-place
image and deleting a journey photo removed the bytes at once, without asking
whether a trip copy, a journey, a saved place or another photo row still
named them (#2924). Those paths now leave the object in place and the reclaim
job removes it once no row names it. A journey photo the user deletes takes
its local photo row with it when nothing else links it, so its bytes become
reclaimable instead of being kept by a row nobody sees.

A place image copied from a trip file is still dropped at once when the
update that would name it fails: that copy was never anyone else's.

Size and warning baselines follow the shrunk files.
This commit is contained in:
Maurice
2026-11-01 13:59:28 +01:00
parent 095bed2db8
commit db0fbc1ccd
19 changed files with 101 additions and 317 deletions
+3 -2
View File
@@ -1301,7 +1301,7 @@ describe('Trip cover upload parity', () => {
expect(fsMod.existsSync(pathMod.join(coversDir, diskName))).toBe(true);
});
it('TRIP-P02 — re-upload deletes the previous cover file', async () => {
it('TRIP-P02 — re-upload keeps the previous cover file for the storage reclaim job (#2924)', async () => {
const { user } = createUser(testDb);
const trip = createTrip(testDb, user.id);
@@ -1317,7 +1317,8 @@ describe('Trip cover upload parity', () => {
.set('Cookie', authCookie(user.id))
.attach('cover', FIXTURE_IMG, 'two.jpg');
expect(second.status).toBe(201);
expect(fsMod.existsSync(pathMod.join(coversDir, firstName))).toBe(false);
// A trip copy or a journey may show the same object, so the replace leaves it.
expect(fsMod.existsSync(pathMod.join(coversDir, firstName))).toBe(true);
});
it('TRIP-P03 — no file → 400 "No image uploaded"', async () => {