fix: invalidate index discographies after library rescan
The search index's Tier 3 (library artists) depends on MBIDs from the artists table. If the index built before a rescan populated those MBIDs, library artists like Flatbush Zombies wouldn't be indexed — they're not in the sitewide top 1000 and their name didn't match via fuzzy matching. Fix: OnAllScansComplete hook now calls InvalidateIndexDiscographies before StartIndexBuild. This clears the discog_built timestamp so Tiers 2-4 re-run incrementally, picking up any new library artists whose MBIDs were just populated by the scan. The rebuild is incremental — only artists not already in the index get their discographies fetched.
This commit is contained in:
@@ -218,6 +218,9 @@ func (yj *YellowJacketApp) OnStartup(ctx context.Context) {
|
|||||||
yj.library.SetScanHooks(library.ScanHooks{
|
yj.library.SetScanHooks(library.ScanHooks{
|
||||||
ResolvePhantoms: yj.playlist.ResolvePhantomTracksAfterScan,
|
ResolvePhantoms: yj.playlist.ResolvePhantomTracksAfterScan,
|
||||||
OnAllScansComplete: func() {
|
OnAllScansComplete: func() {
|
||||||
|
// Force index Tiers 2-4 to re-check for new library
|
||||||
|
// artists whose MBIDs were just populated by the scan.
|
||||||
|
yj.explore.InvalidateIndexDiscographies()
|
||||||
yj.explore.StartIndexBuild()
|
yj.explore.StartIndexBuild()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -78,6 +78,13 @@ func (e *Service) StopIndexBuild() {
|
|||||||
e.index.StopBuild()
|
e.index.StopBuild()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InvalidateIndexDiscographies clears the discography build
|
||||||
|
// timestamp so the next index build re-runs Tiers 2-4. Call
|
||||||
|
// after a library rescan that may have populated new MBIDs.
|
||||||
|
func (e *Service) InvalidateIndexDiscographies() {
|
||||||
|
e.index.InvalidateDiscographies()
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// MusicBrainz search
|
// MusicBrainz search
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -1381,6 +1381,14 @@ func filterUnindexed(artists []lbSitewideArtist, indexed map[string]bool) []lbSi
|
|||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InvalidateDiscographies clears the discography build timestamp
|
||||||
|
// so the next build re-runs Tiers 2-4.
|
||||||
|
func (si *SearchIndex) InvalidateDiscographies() {
|
||||||
|
_, _ = si.db.ExecContext(
|
||||||
|
"DELETE FROM explore_index_meta WHERE key = 'discog_built'",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
func (si *SearchIndex) setMeta(key, value string) {
|
func (si *SearchIndex) setMeta(key, value string) {
|
||||||
if _, err := si.db.ExecContext(
|
if _, err := si.db.ExecContext(
|
||||||
"INSERT OR REPLACE INTO explore_index_meta (key, value) VALUES (?, ?)",
|
"INSERT OR REPLACE INTO explore_index_meta (key, value) VALUES (?, ?)",
|
||||||
|
|||||||
Reference in New Issue
Block a user