diff --git a/backend/app.go b/backend/app.go index 66f5911..18e95d0 100644 --- a/backend/app.go +++ b/backend/app.go @@ -218,6 +218,9 @@ func (yj *YellowJacketApp) OnStartup(ctx context.Context) { yj.library.SetScanHooks(library.ScanHooks{ ResolvePhantoms: yj.playlist.ResolvePhantomTracksAfterScan, 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() }, }) diff --git a/backend/explore/explore.go b/backend/explore/explore.go index e7dc1ba..ee99ba2 100644 --- a/backend/explore/explore.go +++ b/backend/explore/explore.go @@ -78,6 +78,13 @@ func (e *Service) StopIndexBuild() { 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 // --------------------------------------------------------------------------- diff --git a/backend/explore/searchindex.go b/backend/explore/searchindex.go index 3380e69..891967d 100644 --- a/backend/explore/searchindex.go +++ b/backend/explore/searchindex.go @@ -1381,6 +1381,14 @@ func filterUnindexed(artists []lbSitewideArtist, indexed map[string]bool) []lbSi 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) { if _, err := si.db.ExecContext( "INSERT OR REPLACE INTO explore_index_meta (key, value) VALUES (?, ?)",