feat(server/m7-cover-sources): album enricher uses provider chain
Rewires EnrichAlbum to iterate EnabledAlbumProviders from the SettingsService instead of a single hardcoded MBCAA fetcher. Sidecar layer is unchanged (always tried first). Per-row eligibility check honors cover_art_sources_version: terminal 'found' values skip; 'none' flips to NULL via ClearAlbumCoverNone and proceeds (the DB- level ListAlbumsMissingCover query guards the version check for batch callers; RetryAlbum clears via ClearAlbumCover first); NULL is eligible. The provider chain uses an inline allWere404 accumulator to settle the row to 'none' only when every provider returned ErrNotFound. Any provider returning ErrTransient leaves the row NULL for next- pass retry — even if other providers returned ErrNotFound — since the transient call's MBID might succeed on a future attempt. Boot wiring (cmd/minstrel/main.go) replaces the NewFetcher+NewEnricher(fetcher, mbcaaOn) shape with NewMBCAAProviderFromConfig (swaps in production User-Agent on the registered provider) + NewSettingsService + NewEnricher(settings). The old cfg.Library.CoverArtFromMBCAA flag is no-op'd; DB-backed settings replace it. Field stays in the config struct for backward compat with deployed config files. Consolidates fetcher.go's HTTP logic into provider_mbcaa.go (no more wrapper indirection): mbcaaProvider now holds cfg/mu/lastCall/client directly. Deletes fetcher.go and fetcher_test.go. ErrNotFound and ErrTransient move into provider.go alongside the other sentinels. Updates admin_covers_test.go and provider_mbcaa_test.go to the new constructor shapes. Adds multi-provider-chain, transient-leaves-null, and stale-none-flips-and-retries test cases in enricher_test.go. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -89,9 +89,16 @@ var ErrNotTestable = errors.New("coverart: provider does not support test connec
|
||||
// registered.
|
||||
var ErrProviderNotFound = errors.New("coverart: provider not registered")
|
||||
|
||||
// (Note: ErrNotFound and ErrTransient remain declared in fetcher.go
|
||||
// during this task. They move to this file in the next commit when
|
||||
// fetcher.go is deleted as part of the MBCAA refactor.)
|
||||
// ErrNotFound indicates the upstream confirmed there is no art for
|
||||
// this MBID — a terminal-this-pass result. The enricher treats this
|
||||
// as "try the next provider in the chain"; if all providers return
|
||||
// ErrNotFound, the row settles to cover_art_source='none'.
|
||||
var ErrNotFound = errors.New("coverart: not found")
|
||||
|
||||
// ErrTransient indicates a temporary failure (5xx, network, timeout,
|
||||
// auth issue). The enricher leaves the row's source NULL so the next
|
||||
// scan pass can retry.
|
||||
var ErrTransient = errors.New("coverart: transient error")
|
||||
|
||||
// registry is the package-private list of all compiled-in providers.
|
||||
// Providers register at init() via Register(). The enricher iterates
|
||||
|
||||
Reference in New Issue
Block a user