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

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:
2026-11-21 20:51:14 -05:00
co-authored by Claude Opus 5.5
parent dabe1e052d
commit 55c7497ca7
277 changed files with 521 additions and 40021 deletions
+14 -60
View File
@@ -11,7 +11,6 @@ import (
"github.com/jackc/pgx/v5/pgtype"
"github.com/jackc/pgx/v5/pgxpool"
"git.fabledsword.com/bvandeusen/minstrel/internal/acquire"
"git.fabledsword.com/bvandeusen/minstrel/internal/audit"
"git.fabledsword.com/bvandeusen/minstrel/internal/db/dbq"
"git.fabledsword.com/bvandeusen/minstrel/internal/musicbrainz"
@@ -29,8 +28,8 @@ import (
// three of an album's tracks). The album's MusicBrainz track list
// says how long each slot's song is. When exactly one slot's song is as
// long as the file and every other slot's song is clearly not, the copies
// in the other slots are removed and their tracks marked missing, so the
// reacquisition sweeper wants the album back and a good copy fills them.
// in the other slots are removed and their tracks marked missing, until a
// good copy fills them.
// When every slot's song is clearly not the file, every copy goes.
// - named: the lengths cannot say (one recording filed as many tracks, each
// cut to its own slot's length), but AcoustID
@@ -40,9 +39,6 @@ import (
// when it is in none of their slots. Same audio that AcoustID does not
// know at all is no copy's song, and every copy goes.
//
// Whenever copies go, the release the files came from is set aside, so the
// album fetched again is not the same files.
//
// Anything less certain stays with an admin, who settles it the same way
// with their own answer (SettleWrongSlot).
@@ -234,11 +230,8 @@ func settleWrongSlots(
if !ok {
continue
}
// Set aside before the files go: a pass that dies between the two
// still does not fetch the same files again.
blocked := blockReleasesHolding(ctx, pool, logger, g)
emptied := emptiedSlots(ctx, q, logger, g, losers, tracks)
n, err := removeWrongSlots(ctx, pool, logger, g, keep, losers, emptied, blocked, pgtype.UUID{})
n, err := removeWrongSlots(ctx, pool, logger, g, keep, losers, emptied, pgtype.UUID{})
removed += n
if err != nil {
logger.Warn("duplicate resolve: removing wrong-slot copies failed", "group_id", syncpkg.FormatUUID(g.id), "err", err)
@@ -261,19 +254,15 @@ var ErrNotWrongSlot = errors.New("library: duplicate group is not one recording
type WrongSlotResult struct {
Kept *MergedCopy
Removed []MergedCopy
// Blocked names the releases set aside. None when the album was imported
// before Minstrel downloaded anything: the same files may come back.
Blocked []string
}
// SettleWrongSlot settles a one-album mismatch the resolver left for the
// admin, with their answer in place of MusicBrainz's lengths and
// AcoustID's. keepID is the copy whose title they say the recording is; an
// invalid id means they cannot say, and every copy goes. Either way it is the
// resolver's own path: the release the files came from is set aside, the
// copies removed are marked missing, and the album is wanted again for them.
// A merge does none of that, and keeps one copy's title whether or not it is
// the audio's.
// resolver's own path: the copies removed are marked missing, and their slots
// wait for a good copy. A merge does none of that, and keeps one copy's title
// whether or not it is the audio's.
//
// Copies sharing the kept copy's title are one song held twice and stay, as in
// wrongSlots: the next sweep finds the pair and the resolver merges it.
@@ -320,9 +309,9 @@ func SettleWrongSlot(
}
}
res := WrongSlotResult{Blocked: blockReleasesHolding(ctx, pool, logger, g)}
var res WrongSlotResult
emptied := emptiedSlots(ctx, q, logger, g, losers, tracks)
n, err := removeWrongSlots(ctx, pool, logger, g, keep, losers, emptied, res.Blocked, actorID)
n, err := removeWrongSlots(ctx, pool, logger, g, keep, losers, emptied, actorID)
if keep >= 0 {
res.Kept = &MergedCopy{TrackID: g.members[keep].TrackID, FilePath: g.members[keep].FilePath}
}
@@ -434,40 +423,9 @@ func groupRecordings(
return ids, true
}
// blockReleasesHolding sets aside the downloads a group's files were imported
// from, and returns their names. An album imported before Minstrel downloaded
// anything has none.
func blockReleasesHolding(ctx context.Context, pool *pgxpool.Pool, logger *slog.Logger, g *resolveGroup) []string {
q := dbq.New(pool)
seen := map[string]bool{}
var names []string
for _, m := range g.members {
grabs, err := q.ListImportedGrabsHolding(ctx, m.FilePath)
if err != nil {
logger.Warn("duplicate resolve: finding the download a file came from failed", "path", m.FilePath, "err", err)
continue
}
for _, gr := range grabs {
if seen[gr.InfoHash] {
continue
}
seen[gr.InfoHash] = true
if err := acquire.NewMemory(pool).Block(ctx, dbq.BlockReleaseParams{
InfoHash: gr.InfoHash, Name: gr.Name, Reason: acquire.BlockFiles,
Detail: "one recording fills several of the album's tracks.", WantID: gr.WantID,
}); err != nil {
logger.Warn("duplicate resolve: setting the release aside failed", "release", gr.Name, "err", err)
continue
}
names = append(names, gr.Name)
}
}
return names
}
// emptiedSlots is the losers whose song the album holds no other copy of:
// no present track on it under that title as long as the song's slot. Those
// wait for a copy fetched again (migration 0095). The rest are the song held
// wait for a good copy to arrive. The rest are the song held
// twice, and missing-pair folding folds them into the copy held: Savant's
// VOID DLC "Weeper" beside Void's. A failed read counts every loser as
// emptied, which only makes the album wait for a copy it may not need.
@@ -515,17 +473,16 @@ func neverRead(ctx context.Context, q *dbq.Queries, rg string) bool {
// removeWrongSlots deletes each loser's file, then marks its track missing in
// the same transaction that closes the group. The row is kept, with its likes
// and plays: it is the slot, and a good copy fetched again takes it over. Its
// recording MBID is dropped, being the wrong file's, so missing-pair folding
// does not fold the slot into the copy that was kept. The slots in emptied
// are stamped to wait for a copy fetched again (emptiedSlots). blocked names
// the releases set aside, for the record. A file that cannot be removed stops
// and plays: it is the slot, and a good copy that arrives later takes it over.
// Its recording MBID is dropped, being the wrong file's, so missing-pair
// folding does not fold the slot into the copy that was kept. The slots in
// emptied are stamped to wait for a good copy (emptiedSlots). A file that cannot be removed stops
// the group; the ones already gone are still marked, and the group waits for
// the next pass. actorID is the admin settling it by hand, invalid for the
// resolver.
func removeWrongSlots(
ctx context.Context, pool *pgxpool.Pool, logger *slog.Logger, g *resolveGroup, keep int, losers []int,
emptied []pgtype.UUID, blocked []string, actorID pgtype.UUID,
emptied []pgtype.UUID, actorID pgtype.UUID,
) (int, error) {
var gone []pgtype.UUID
var removedFiles []map[string]string
@@ -579,9 +536,6 @@ func removeWrongSlots(
"artist": g.members[0].ArtistName,
"removed": removedFiles,
}
if len(blocked) > 0 {
details["blocked"] = blocked
}
keptPath := ""
if keep >= 0 {
kept := g.members[keep]