feat(scanner): trigger rescan when PID.Artist changes

This commit is contained in:
Deluan 2026-05-24 19:35:03 -03:00
parent 12980e8d88
commit 46cb9f8d58
2 changed files with 16 additions and 1 deletions

View File

@ -175,7 +175,17 @@ func pidHashChanged(ds model.DataStore) (bool, error) {
if err != nil {
return false, err
}
return !strings.EqualFold(pidAlbum, conf.Server.PID.Album) || !strings.EqualFold(pidTrack, conf.Server.PID.Track), nil
pidArtist, err := ds.Property(context.Background()).DefaultGet(consts.PIDArtistKey, "")
if err != nil {
return false, err
}
// Empty stored value is treated as matching — fresh upgrade should not force a rescan.
if pidArtist == "" {
pidArtist = conf.Server.PID.Artist
}
return !strings.EqualFold(pidAlbum, conf.Server.PID.Album) ||
!strings.EqualFold(pidTrack, conf.Server.PID.Track) ||
!strings.EqualFold(pidArtist, conf.Server.PID.Artist), nil
}
// runInitialScan runs an initial scan of the music library if needed.

View File

@ -309,6 +309,11 @@ func (s *scannerImpl) runUpdateLibraries(ctx context.Context, state *scanState)
log.Error(ctx, "Scanner: Error updating album PID conf", err)
return fmt.Errorf("updating album PID conf: %w", err)
}
err = tx.Property(ctx).Put(consts.PIDArtistKey, conf.Server.PID.Artist)
if err != nil {
log.Error(ctx, "Scanner: Error updating artist PID conf", err)
return fmt.Errorf("updating artist PID conf: %w", err)
}
if state.changesDetected.Load() {
log.Debug(ctx, "Scanner: Refreshing library stats", "lib", lib.Name)
if err := tx.Library(ctx).RefreshStats(lib.ID); err != nil {