fix(server/m7-379): enricher leaves cover_art_source NULL when MBID missing
This commit is contained in:
@@ -63,11 +63,15 @@ func (e *Enricher) EnrichAlbum(ctx context.Context, albumID pgtype.UUID) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Step 2: MBCAA fallback. Requires fetcher + toggle on + MBID.
|
// Step 2: MBCAA fallback. Requires fetcher + toggle on + MBID.
|
||||||
|
// When the toggle is disabled OR the album has no MBID, leave
|
||||||
|
// cover_art_source NULL so a future scan can retry once the
|
||||||
|
// scanner heals the MBID. 'none' is reserved for genuine MBCAA
|
||||||
|
// 404s where we know the album really isn't in the archive.
|
||||||
if !e.mbcaaOn || e.fetcher == nil {
|
if !e.mbcaaOn || e.fetcher == nil {
|
||||||
return e.recordCover(ctx, albumID, "", "none")
|
return nil
|
||||||
}
|
}
|
||||||
if row.Mbid == nil || *row.Mbid == "" {
|
if row.Mbid == nil || *row.Mbid == "" {
|
||||||
return e.recordCover(ctx, albumID, "", "none")
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := e.fetcher.Fetch(ctx, *row.Mbid)
|
body, err := e.fetcher.Fetch(ctx, *row.Mbid)
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ func TestEnrichAlbum_SidecarFound(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEnrichAlbum_NoSidecarNoMBID_RecordsNone(t *testing.T) {
|
func TestEnrichAlbum_NoSidecarNoMBID_LeavesNull(t *testing.T) {
|
||||||
pool := newPool(t)
|
pool := newPool(t)
|
||||||
id, _ := seedAlbumWithTrack(t, pool, "NoMbid", "Artist", "")
|
id, _ := seedAlbumWithTrack(t, pool, "NoMbid", "Artist", "")
|
||||||
e := NewEnricher(pool, discardLogger(), nil, true)
|
e := NewEnricher(pool, discardLogger(), nil, true)
|
||||||
@@ -112,8 +112,8 @@ func TestEnrichAlbum_NoSidecarNoMBID_RecordsNone(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("get: %v", err)
|
t.Fatalf("get: %v", err)
|
||||||
}
|
}
|
||||||
if row.CoverArtSource == nil || *row.CoverArtSource != "none" {
|
if row.CoverArtSource != nil {
|
||||||
t.Errorf("source = %v, want 'none'", row.CoverArtSource)
|
t.Errorf("source = %v, want nil (NULL — eligible for retry on next scan)", row.CoverArtSource)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user