fix(admin): re-acquisition settings take effect without a restart, and say why a save was refused (#3936, #3937)
test-web / test (push) Successful in 1m9s
test-go / test (push) Successful in 1m28s
test-go / integration (push) Successful in 3m57s
release / Build signed APK (releases and dev) (push) Successful in 5m20s
release / Build + push container image (push) Successful in 1m23s
release / Verify release artifacts (tag releases only) (push) Skipped

#3936: Router() built a reacquisition.SettingsService of its own, so a save
from the admin card refreshed that instance's cache while the sweeper in
main.go kept serving what it loaded at boot. The card showed the new
policy, the feature ran the old one, and only a restart reconciled them.
main.go now hands its instance to the server (srv.ReacqSettings), as it
already did for RecSettings, TagSettings and FingerprintSettings, and
Router() constructs one only when that field is nil. The regression test
saves through the router and reads the sweeper's instance.

#3937: the card's catch tested `e instanceof Error`, but api.put throws a
plain {code, message, status} object, so every reason the server gave was
discarded in favour of "Couldn't save settings." It now uses errMessage,
which appends the server's message for invalid_setting. Its test rejected
with an Error no code path produces, so it passed throughout; it now
rejects with what the client actually throws.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SQ31KQpYbStyK5y58UmPLH
This commit is contained in:
2026-09-11 20:15:35 -04:00
co-authored by Claude Opus 5
parent 37d4906033
commit 516413f4ca
5 changed files with 144 additions and 13 deletions
+17 -7
View File
@@ -105,6 +105,11 @@ type Server struct {
// fingerprint workers, so a save from the admin card reaches them without a
// restart. Router() constructs a fallback when nil (tests).
FingerprintSettings *library.FingerprintSettingsService
// ReacqSettings is the DB-backed missing-file re-acquisition policy
// (milestone #290) — the same instance the sweeper in cmd/minstrel/main.go
// reads, so a save from the admin card reaches it without a restart
// (#3936). Router() constructs a fallback when nil (tests).
ReacqSettings *reacquisition.SettingsService
// StreamSecret is the HMAC key used by /api/cast/stream-token to
// mint signed UPnP / Sonos stream URLs and by /api/tracks/{id}/stream
// to verify them. Sourced from config.Config.StreamSecret. Tests that
@@ -157,13 +162,18 @@ func (s *Server) Router() http.Handler {
return lidarr.NewClient(cfg.BaseURL, cfg.APIKey)
}
lidarrReqs := lidarrrequests.NewService(s.Pool, lidarrCfg, lidarrClientFn, nil)
// Always usable even when the load fails — it falls back to the
// shipped defaults rather than leaving the admin card unable to
// render (same posture as netsettings above).
reacqSettings, raErr := reacquisition.NewSettingsService(
context.Background(), s.Pool, s.Logger)
if raErr != nil {
s.Logger.Warn("reacquisition settings unavailable; serving defaults", "err", raErr)
reacqSettings := s.ReacqSettings
if reacqSettings == nil {
// Test contexts construct Server without main.go's boot wiring.
// Always usable even when the load fails — it falls back to the
// shipped defaults rather than leaving the admin card unable to
// render (same posture as netsettings above).
var raErr error
reacqSettings, raErr = reacquisition.NewSettingsService(
context.Background(), s.Pool, s.Logger)
if raErr != nil {
s.Logger.Warn("reacquisition settings unavailable; serving defaults", "err", raErr)
}
}
lidarrQuar := lidarrquarantine.NewService(s.Pool, lidarrCfg, lidarrClientFn, s.DataDir)
tracksSvc := tracks.NewService(s.Pool, s.Logger, lidarrUnmonitorAdapter{fn: lidarrClientFn}, s.DataDir)