Skip to content

fix(backup): store media under media/<id>/<filename> so same-named files cannot overwrite each other - #4

Merged
amenophis1er merged 1 commit into
mainfrom
fix/media-archive-collisions
Sep 13, 2026
Merged

amenophis1er merged 1 commit into
mainfrom
fix/media-archive-collisions

Conversation

@amenophis1er

@amenophis1er amenophis1er commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

'trokky backup' wrote every media file to the archive as media/. A zip tolerates duplicate entry names, so the archive appeared
complete, but 'trokky restore' built a filename -> entry map where the last
entry won and uploaded that one for every media id sharing the name.

On one production instance 94 of 662 filenames are shared between media
ids. 86 are byte-identical copies, harmless; 8 names cover 84 ids that are
different photos (Photo-de-famille.jpg x17, Vue-partielle-des-participants.jpg
x24). A restore reported 942/942 with 0 failed and ~76 photos came back as the
wrong image.

Entries are now scoped by media id, and the manifest records each item's
archivePath. Restore resolves the manifest path first, then the id-scoped
layout, then the flat legacy layout — and when it has to fall back to a legacy
entry that several ids share, it warns that the bytes may be wrong and that a
fresh backup is needed. Old archives with collisions cannot be repaired: the
overwritten bytes were never written.

…les cannot overwrite each other

'trokky backup' wrote every media file to the archive as media/<original
filename>. A zip tolerates duplicate entry names, so the archive appeared
complete, but 'trokky restore' built a filename -> entry map where the last
entry won and uploaded that one for every media id sharing the name.

On the Cour des Comptes instance 94 of 662 filenames are shared between media
ids. 86 are byte-identical copies, harmless; 8 names cover 84 ids that are
different photos (Photo-de-famille.jpg x17, Vue-partielle-des-participants.jpg
x24). A restore reported 942/942 with 0 failed and ~76 photos came back as the
wrong image.

Entries are now scoped by media id, and the manifest records each item's
archivePath. Restore resolves the manifest path first, then the id-scoped
layout, then the flat legacy layout — and when it has to fall back to a legacy
entry that several ids share, it warns that the bytes may be wrong and that a
fresh backup is needed. Old archives with collisions cannot be repaired: the
overwritten bytes were never written.
@amenophis1er
amenophis1er merged commit 0e56e79 into main Sep 13, 2026
1 check passed
@amenophis1er
amenophis1er deleted the fix/media-archive-collisions branch September 13, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant