fix(library): the duplicate resolver never removes a file on its own (#8252)
release / go (push) Successful in 2m28s
release / web (push) Successful in 1m42s
release / govulncheck (push) Successful in 23s
release / integration (push) Successful in 5m9s
release / android (push) Successful in 5m28s
release / Build signed APK (push) Successful in 5m54s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Publish the release image to GHCR (dispatch only) (push) Skipped
release / Build + push container image (push) Successful in 34s
release / Verify release artifacts (tag releases only) (push) Skipped

Other programs file music into the library now, and a startup pass
deleted a whole album a download manager had just filed, keeping older
loose copies of the same songs. The resolver assumed Minstrel was the
only program writing the library; it is not.

An automatic pass now changes only Minstrel's database:
- copies of one song, on one album or across releases, are linked as one
  song, so likes, plays and mixes count it once, and any group an admin
  may want to thin stays pending for review (and is announced);
- distinct versions are still dismissed, and rips still held back;
- a one-album wrong slot gets a note naming the song MusicBrainz or
  AcoustID says the recording is, for the admin who settles it.

Removing a copy is an admin's merge or wrong-slot settle, as before. When
an admin merges, a copy in a folder named for its album ("Album (Year)",
or its "CD nn" folder) now outranks a loose copy of the same audio.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-30 21:09:11 -05:00
co-authored by Claude Opus 5.5
parent 63af193b13
commit 677a421675
16 changed files with 330 additions and 462 deletions
+8 -9
View File
@@ -6,12 +6,12 @@ import (
"time"
)
// filesGate keeps reading the library's files apart from removing them. A
// full scan holds it for its whole length and the watcher for each batch;
// a duplicate-resolver pass, which removes the copies it merges, runs only
// while no one else holds it. Without it, a file a scan has listed could be
// removed under the scan, and a file read just before its removal would put
// back a track whose file is gone.
// filesGate keeps a library scan and a duplicate-resolver pass from running
// at once. A full scan holds it for its whole length and the watcher for each
// batch; a resolver pass runs only while no one else holds it. The scan
// rewrites tracks from the files it reads, and the pass decides from those
// tracks which copies are one song: run together, the pass would decide from
// a library half-read.
//
// A scan that starts during a resolver pass waits for the pass to finish,
// up to filesWaitLimit. A resolver pass that finds the gate taken is put off
@@ -19,9 +19,8 @@ import (
var filesGate = make(gate, 1)
// filesWaitLimit is how long a scan waits for a resolver pass to let go of
// the files. A pass is capped at resolveMergeCap merges and takes minutes;
// one still holding them after this long is stuck, and the scan gives up
// rather than wait forever.
// the files. A pass takes minutes; one still holding them after this long is
// stuck, and the scan gives up rather than wait forever.
const filesWaitLimit = 30 * time.Minute
// errFilesBusy is a scan giving up on a resolver pass that held the files