feat(album): preserve uploaded cover across album-id changes

This commit is contained in:
Deluan 2026-07-17 18:54:33 -04:00
parent 720993fe7c
commit 75c11cab81
2 changed files with 9 additions and 2 deletions

View File

@ -96,6 +96,13 @@ var _ = Describe("AlbumRepository", func() {
Expect(err).ToNot(HaveOccurred())
Expect(got.CreatedAt).To(BeTemporally("~", dstTime, time.Second))
})
It("copies uploaded_image from source to destination", func() {
Expect(albumRepo.UpdateImage("copy-src", "copy-src_cover.jpg")).To(Succeed())
Expect(albumRepo.CopyAttributes("copy-src", "copy-dst", "uploaded_image")).To(Succeed())
got, err := albumRepo.Get("copy-dst")
Expect(err).ToNot(HaveOccurred())
Expect(got.UploadedImage).To(Equal("copy-src_cover.jpg"))
})
})
Describe("GetCursor", func() {

View File

@ -449,8 +449,8 @@ func (p *phaseFolders) persistAlbum(repo model.AlbumRepository, a *model.Album,
p.state.sendWarning(fmt.Sprintf("Could not reassign annotations from %s to %s ('%s'): %v", prevID, a.ID, a.Name, err))
}
// Keep created_at field from previous instance of the album
if err := repo.CopyAttributes(prevID, a.ID, "created_at"); err != nil {
// Keep created_at and any uploaded cover from the previous instance of the album
if err := repo.CopyAttributes(prevID, a.ID, "created_at", "uploaded_image"); err != nil {
// Silently ignore when the previous album is not found
if !errors.Is(err, model.ErrNotFound) {
log.Warn(p.ctx, "Scanner: Could not copy fields", "from", prevID, "to", a.ID, "album", a.Name, err)