fix(artwork): enqueue uploaded artwork only after the filename is persisted

SetImage cleared state and enqueued the bump before the caller stored the new
filename, so a worker drain in that window could resolve against the old (already
deleted) file and settle absent, leaving the upload unused until a later scan. Move
the invalidate+enqueue into EnqueueArtwork, which each caller now invokes after the
entity Put.
This commit is contained in:
Deluan 2026-07-23 00:43:04 -04:00
commit 66d3d23149
5 changed files with 44 additions and 8 deletions

View file

@ -46,7 +46,11 @@ func (api *Router) uploadArtistImage() http.HandlerFunc {
}
ar.UploadedImage = filename
ar.UpdatedAt = new(time.Now())
return api.ds.Artist(ctx).Put(ar, "uploaded_image", "updated_at")
if err := api.ds.Artist(ctx).Put(ar, "uploaded_image", "updated_at"); err != nil {
return err
}
api.imgUpload.EnqueueArtwork(ctx, consts.EntityArtist, ar.ID)
return nil
})
}

View file

@ -47,7 +47,11 @@ func (api *Router) uploadRadioImage() http.HandlerFunc {
return err
}
radio.UploadedImage = filename
return api.ds.Radio(ctx).Put(radio, "UploadedImage")
if err := api.ds.Radio(ctx).Put(radio, "UploadedImage"); err != nil {
return err
}
api.imgUpload.EnqueueArtwork(ctx, consts.EntityRadio, radio.ID)
return nil
})
}