fix(images): purge removes every archive cover, the id of an emptied album moves on

- The covers that come from the Cover Art Archive now live in a folder of their own
  (images/album-remote). Taking the provider's data back deletes that folder, so nothing
  from the archive is left whatever became of its records: a rescan makes a record stale
  and a later search that finds nothing replaces it, and neither of those used to remove
  the files. A cover that moves between the user's files and the archive, or goes away,
  no longer leaves the old files behind.
- A redirect to a place that is not allowed is an outage (502, not remembered, an older
  cover served), not "no cover" for a day for every album. A picture over the limit is
  still "no cover".
- A track that moves to another album (a fixed title) leaves the first with no track: it
  gives up its release group id, so the album the track went to can take it. An album
  that has an id keeps it; an id another album owns is not given twice.
- Waiting for a local slot is no longer reported as the provider being unreachable, and a
  build whose reads were purged three times is not served with files that were never written.
- README and spec no longer say covers never contact anybody.
- Tests: the new folder and the purge after a rescan, files left by a replaced cover, the
  local wait, repeated purges, a refused redirect, the update path with a taken id and the
  emptied album.
This commit is contained in:
tgiachi 2026-11-12 09:21:11 +01:00
commit 5fecd394e4

View file

@ -212,16 +212,12 @@ func run() error {
return out, nil
case providers.CoverArtArchive:
pictures.BeginPurge()
// The records say which albums have a cover from the archive: read them before they go.
ids, err := imageRepo.OwnersBySource(ctx, "album", images.SourceCoverArt)
if err != nil {
return providers.Purged{}, err
}
out, err := discoveryRepo.Purge(ctx, name)
if err != nil {
return out, err
}
if _, err := pictures.RemoveAlbumFiles(ids); err != nil {
// The covers that came from the archive have a folder of their own: all of it goes.
if _, err := pictures.RemoveRemoteAlbumFiles(); err != nil {
return out, fmt.Errorf("remove the covers: %w", err)
}
return out, nil