Commit graph

4 commits

Author SHA1 Message Date
Deluan
a79e670740 fix(album): serialize cover upload/delete to close shared-file races
The shared-file handling is check-then-act (CountByImage, then remove/write):
two concurrent deletes on albums sharing one file could both see refs>1, both
skip removal, and both clear their rows — leaving the file orphaned with no
remaining reference for the purge GC to find. Serialize album image
operations behind a mutex; they are rare, admin-gated actions.
2026-07-18 02:07:07 -04:00
Deluan
ee7c4d3b88 fix(album): never write over a cover file shared by another album
The shared-file guard stopped deletion, but re-uploading a cover on the album
whose id matches the shared filename derived the same deterministic path, and
SetImage's os.Create truncated the file the other album still references —
silently changing its cover too.

When the current file is shared, upload under a de-duplicated name so the
derived filename is unique; the shared file stays intact for the other row
and the purge GC reaps it when the last reference goes.
2026-07-17 23:36:08 -04:00
Deluan
83ae195c10 fix(album): don't delete cover files still shared by another album row
After an album-ID copy (e.g. a partial track move), two album rows can
reference the same uploaded image file. Replacing or deleting the cover on
one of them removed the shared file out from under the other.

Add AlbumRepository.CountByImage (unfiltered by library) and skip the file
removal in the upload/delete handlers when the filename is referenced by more
than one row; the purge GC reaps the file when the last reference goes.
2026-07-17 23:16:10 -04:00
Deluan
940dbe4c0a feat(album): add cover upload/delete API endpoints 2026-07-17 19:02:14 -04:00