fix(library): extract recording MBID → tracks.mbid; unblock LB similarity
tracks.mbid was 100% NULL: the scanner only extracted album + artist MBIDs, never the recording MBID. The ListenBrainz similarity worker is gated on tracks.mbid IS NOT NULL, so track_similarity could never populate — starving For-You/radio's strongest candidate source (lb_similar) on every library. - mbids.go: add extractRecordingMBID (mbz.Recording / Picard musicbrainz_recordingid). Separate fn so extractMBIDs' signature + unit tests stay untouched. - scanner.go: persist recording MBID via UpsertTrack (heals on the file_path conflict, so re-scans backfill for free). - BackfillTrackMBIDs: one-shot pass mirroring BackfillMBIDs, wired as scan Stage 2b (idempotent via SetTrackMbidIfNull, gated by BackfillCap, log-only progress). - migration 0029: tracks_mbid_unique (0002, written when the column was always NULL) wrongly assumes one MBID == one track. A recording appears on multiple releases, so rows legitimately share a recording MBID. Replace with a non-unique partial index. Zero-risk: column is 100% NULL at migration time. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -154,6 +154,16 @@ func RunScan(
|
||||
}
|
||||
}
|
||||
|
||||
// Stage 2b: track recording-MBID backfill. Unblocks the ListenBrainz
|
||||
// similarity pipeline (gated on tracks.mbid IS NOT NULL). Log-only
|
||||
// progress — no scan_runs jsonb column to avoid a schema addition;
|
||||
// it's idempotent and reruns each scan until every file is healed.
|
||||
if cfg.BackfillCap != 0 {
|
||||
if _, tberr := BackfillTrackMBIDs(ctx, pool, logger, cfg.BackfillCap, nil); tberr != nil {
|
||||
captureErr("track_mbid_backfill", tberr)
|
||||
}
|
||||
}
|
||||
|
||||
// Stage 3: cover enrichment.
|
||||
if enricher != nil && cfg.EnrichCap != 0 {
|
||||
var lastP, lastS, lastF int
|
||||
|
||||
Reference in New Issue
Block a user