fix: address code review findings
This commit is contained in:
@@ -2,6 +2,7 @@ package scanner
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"naviwatcher/internal/database"
|
||||
)
|
||||
@@ -55,9 +56,12 @@ func ScanAll(ctx context.Context, db *database.DB, threshold float64) ([]Missing
|
||||
if !s.Monitored {
|
||||
continue
|
||||
}
|
||||
// A transient error for one artist must not abort the whole scan and
|
||||
// take down the daemon; log it and continue with the remaining artists.
|
||||
missing, err := ScanArtist(ctx, db, s.ID, resolved)
|
||||
if err != nil {
|
||||
return all, err
|
||||
log.Printf("scan artist %s failed: %v", s.ID, err)
|
||||
continue
|
||||
}
|
||||
all = append(all, missing...)
|
||||
}
|
||||
|
||||
@@ -139,6 +139,35 @@ func TestScanArtist_RemasteredVariantNotMissing(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestScanArtist_YearTitledAlbumReissueReportedMissing(t *testing.T) {
|
||||
db := newTestDB(t)
|
||||
defer db.Close()
|
||||
|
||||
// Rush "2112" is a bare year-titled album; "2112 (Remastered)" is a
|
||||
// distinct release group. Owning the standard 2112 must NOT count as owning
|
||||
// the remastered reissue — the reissue should be reported missing.
|
||||
seedArtist(t, db, "artist-1", "Rush")
|
||||
seedLocalAlbum(t, db, "l1", "artist-1", "2112")
|
||||
seedExternalRelease(t, db, "rg-standard", "artist-1", "2112", false)
|
||||
seedExternalRelease(t, db, "rg-remaster", "artist-1", "2112 (Remastered)", false)
|
||||
|
||||
missing, err := ScanArtist(context.Background(), db, "artist-1", 0)
|
||||
if err != nil {
|
||||
t.Fatalf("ScanArtist() error: %v", err)
|
||||
}
|
||||
|
||||
rgids := map[string]bool{}
|
||||
for _, m := range missing {
|
||||
rgids[m.RGID] = true
|
||||
}
|
||||
if rgids["rg-standard"] {
|
||||
t.Errorf("standard 2112 should match local copy, not be missing")
|
||||
}
|
||||
if !rgids["rg-remaster"] {
|
||||
t.Errorf("2112 (Remastered) reissue should be reported missing, got %v", rgids)
|
||||
}
|
||||
}
|
||||
|
||||
func TestScanArtist_CtxCancelled(t *testing.T) {
|
||||
db := newTestDB(t)
|
||||
defer db.Close()
|
||||
|
||||
Reference in New Issue
Block a user