feat: Minstrel stops acquiring music and drops Discover
release / go (push) Successful in 1m54s
release / web (push) Failing after 5s
release / integration (push) Failing after 3m44s
release / govulncheck (push) Successful in 20s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / Build signed APK (push) Canceled after 19s
release / android (push) Canceled after 2m37s
release / go (push) Successful in 1m54s
release / web (push) Failing after 5s
release / integration (push) Failing after 3m44s
release / govulncheck (push) Successful in 20s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / Build signed APK (push) Canceled after 19s
release / android (push) Canceled after 2m37s
Minstrel is now a viewer of the library it is pointed at. Finding, downloading and filing music moves out of it. Removed from the server: - the request flow (requests, approval, auto-approve) and the wanted list, follows, release profiles and release blocks; - searching indexers, the download clients, the importer, the album lifecycle and missing-file re-acquisition; - the catalogue's discography, search and art (the MusicBrainz release and track-list cache stays, for the duplicate resolver); - Discover: its suggestions of artists not in the library, snoozes, the candidate-artist tag enrichment and its tuning scope; - writes to acquisition tables from moving the library folder and from merging duplicates, the want-list join on Suspect sources, the sealing of acquisition credentials, and the release-group lookup only re-acquisition used. Settling a wrong-slot duplicate no longer sets the release aside: the copies go and their slots show as missing until a good copy is in the library. Removed from the web: Admin > Acquisition and Requests, /requests, /discover, Follow on the artist page, the auto-approve toggle, and the Collection's wanted-list tabs. The Collection is now the library's health: an overview, Reports, Duplicates, Suspect sources and Missing files. The README and docs no longer describe getting music. The tables stay for now; a later migration drops them. The request notification kinds and the Android screens are still to go. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,9 +26,7 @@ import (
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/playevents"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/playlists"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/quarantine"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/reacquisition"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/recsettings"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/requests"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/subsonic"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/tags"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/tracks"
|
||||
@@ -90,11 +88,6 @@ type Server struct {
|
||||
// status and "look up now" the admin card drives. Nil in test contexts;
|
||||
// one is built (and never run) so the admin routes still answer.
|
||||
AcoustIDLookup *library.AcoustIDLookupWorker
|
||||
// ReacqSettings is the DB-backed missing-file re-acquisition policy — the
|
||||
// same instance the sweeper in cmd/minstrel/main.go reads, so a save from
|
||||
// the admin card reaches it without a restart. Router() constructs a
|
||||
// fallback when nil (tests).
|
||||
ReacqSettings *reacquisition.SettingsService
|
||||
// Backups is the server's own backup, the instance whose loop runs the
|
||||
// nightly schedule. Nil builds one that runs only when an admin asks.
|
||||
Backups *backup.Service
|
||||
@@ -143,26 +136,12 @@ func (s *Server) Router() http.Handler {
|
||||
s.EventsCfg.SkipMaxCompletionRatio,
|
||||
s.EventsCfg.SkipMaxDurationPlayedMs,
|
||||
)
|
||||
requestSvc := requests.NewService(s.Pool)
|
||||
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)
|
||||
}
|
||||
}
|
||||
quarantineSvc := quarantine.NewService(s.Pool, s.DataDir)
|
||||
tracksSvc := tracks.NewService(s.Pool, s.Logger, s.DataDir)
|
||||
playlistsSvc := playlists.NewService(s.Pool, s.Logger, s.DataDir)
|
||||
smtpSender := mailer.NewSMTPSender(s.Pool, s.Logger.With("component", "mailer"))
|
||||
// Live-event bus for SSE subscribers, one per process: producers in
|
||||
// playevents / requests / scanner publish into the same instance.
|
||||
// playevents / scanner publish into the same instance.
|
||||
// Background workers are built in cmd/minstrel/main.go before Router()
|
||||
// runs and share s.Bus. With no bus set (tests), a fresh local one is
|
||||
// used.
|
||||
@@ -211,7 +190,7 @@ func (s *Server) Router() http.Handler {
|
||||
if backups == nil {
|
||||
backups = backup.NewService(s.Pool, s.Logger, buildinfo.Version)
|
||||
}
|
||||
api.Mount(r, s.Pool, s.Logger, writer, s.RecommendationCfg, recSettings, requestSvc, quarantineSvc, tracksSvc, playlistsSvc, s.CoverEnricher, s.CoverSettings, s.TagSettings, s.LibraryScanner, s.ScanCfg, s.DataDir, smtpSender, bus, s.PlaylistScheduler, s.StreamSecret, netSettings, reacqSettings, fpSettings, loudSettings, acoustIDLookup, backups, s.Restart)
|
||||
api.Mount(r, s.Pool, s.Logger, writer, s.RecommendationCfg, recSettings, quarantineSvc, tracksSvc, playlistsSvc, s.CoverEnricher, s.CoverSettings, s.TagSettings, s.LibraryScanner, s.ScanCfg, s.DataDir, smtpSender, bus, s.PlaylistScheduler, s.StreamSecret, netSettings, fpSettings, loudSettings, acoustIDLookup, backups, s.Restart)
|
||||
// /api/admin/scan is the only admin route owned by the server package
|
||||
// (it needs the Scanner). Register it as a single inline-middleware
|
||||
// route — using r.Route("/api/admin", ...) here would create a second
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io"
|
||||
@@ -21,7 +20,6 @@ import (
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/db"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/db/dbq"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/library"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/reacquisition"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/subsonic"
|
||||
)
|
||||
|
||||
@@ -242,104 +240,6 @@ func TestRouter_AdminSubtreeNotShadowed(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestRouter_ReacquisitionSettingsSavedThroughTheAPIReachTheSweeper: a
|
||||
// Router() that built a reacquisition.SettingsService of its own would refresh
|
||||
// THAT instance's cache on a save, while the sweeper in cmd/minstrel/main.go
|
||||
// kept serving what it loaded at boot. The card would show the new policy and
|
||||
// the feature run the old one until a restart.
|
||||
//
|
||||
// The assertion is made against the instance main.go hands the sweeper: save
|
||||
// through the router, then read that instance. A second service leaves it stale.
|
||||
func TestRouter_ReacquisitionSettingsSavedThroughTheAPIReachTheSweeper(t *testing.T) {
|
||||
dsn := os.Getenv("MINSTREL_TEST_DATABASE_URL")
|
||||
if dsn == "" {
|
||||
t.Skip("MINSTREL_TEST_DATABASE_URL not set")
|
||||
}
|
||||
logger := slog.New(slog.NewTextHandler(io.Discard, nil))
|
||||
if err := db.Migrate(dsn, logger); err != nil {
|
||||
t.Fatalf("migrate: %v", err)
|
||||
}
|
||||
pool, err := pgxpool.New(context.Background(), dsn)
|
||||
if err != nil {
|
||||
t.Fatalf("pool: %v", err)
|
||||
}
|
||||
t.Cleanup(pool.Close)
|
||||
|
||||
ctx := context.Background()
|
||||
q := dbq.New(pool)
|
||||
_, _ = pool.Exec(ctx, "DELETE FROM sessions WHERE user_agent = 'reacq-settings-test'")
|
||||
_, _ = pool.Exec(ctx, "DELETE FROM users WHERE username = 'test-reacq-settings-admin'")
|
||||
user, err := q.CreateUser(ctx, dbq.CreateUserParams{
|
||||
Username: "test-reacq-settings-admin",
|
||||
PasswordHash: "x",
|
||||
ApiTokenHash: "test-reacq-settings-token",
|
||||
IsAdmin: true,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("CreateUser: %v", err)
|
||||
}
|
||||
t.Cleanup(func() { _, _ = pool.Exec(ctx, "DELETE FROM users WHERE id = $1", user.ID) })
|
||||
token := "reacq-settings-test-" + time.Now().Format("20060102150405.000000")
|
||||
tokenHash := auth.HashSessionToken(token)
|
||||
if _, err := pool.Exec(ctx,
|
||||
"INSERT INTO sessions (user_id, token_hash, user_agent) VALUES ($1, $2, 'reacq-settings-test')",
|
||||
user.ID, tokenHash[:],
|
||||
); err != nil {
|
||||
t.Fatalf("insert session: %v", err)
|
||||
}
|
||||
|
||||
// The sweeper's service. Nothing else in the process may write to the
|
||||
// settings for the assertion below to mean what it says.
|
||||
sweeperSettings, err := reacquisition.NewSettingsService(ctx, pool, logger)
|
||||
if err != nil {
|
||||
t.Fatalf("reacquisition settings: %v", err)
|
||||
}
|
||||
before := sweeperSettings.Get()
|
||||
t.Cleanup(func() {
|
||||
if _, err := sweeperSettings.Set(context.Background(), before); err != nil {
|
||||
t.Errorf("restore reacquisition settings: %v", err)
|
||||
}
|
||||
})
|
||||
wantGrace := before.GraceHours + 1
|
||||
if wantGrace > 720 {
|
||||
wantGrace = before.GraceHours - 1
|
||||
}
|
||||
|
||||
s := New(logger, pool, stubScanner{}, subsonic.Config{}, config.EventsConfig{},
|
||||
config.RecommendationConfig{}, "", config.BrandingConfig{}, nil, nil, nil, library.RunScanConfig{})
|
||||
s.ReacqSettings = sweeperSettings
|
||||
ts := httptest.NewServer(s.Router())
|
||||
defer ts.Close()
|
||||
|
||||
body, err := json.Marshal(map[string]any{
|
||||
"enabled": before.Enabled,
|
||||
"grace_hours": wantGrace,
|
||||
"max_per_pass": before.MaxPerPass,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("marshal: %v", err)
|
||||
}
|
||||
req, err := http.NewRequest(http.MethodPut, ts.URL+"/api/admin/library/reacquisition", bytes.NewReader(body))
|
||||
if err != nil {
|
||||
t.Fatalf("build request: %v", err)
|
||||
}
|
||||
req.Header.Set("Authorization", "Bearer "+token)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("PUT reacquisition settings: %v", err)
|
||||
}
|
||||
defer func() { _ = resp.Body.Close() }()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Fatalf("PUT reacquisition settings: status = %d, want 200", resp.StatusCode)
|
||||
}
|
||||
|
||||
if got := sweeperSettings.Get().GraceHours; got != wantGrace {
|
||||
t.Fatalf("the sweeper's settings hold grace_hours = %d after the save, want %d — "+
|
||||
"the API wrote through a different service instance", got, wantGrace)
|
||||
}
|
||||
}
|
||||
|
||||
// stubScanner is a no-op ScanTrigger used only to make Server.Router()
|
||||
// register /api/admin/scan. Its Scan method must never be called by the
|
||||
// route-presence assertions in this file.
|
||||
|
||||
Reference in New Issue
Block a user