Loosen approximate matching and link to the album version's folders

Matching:
- Prefer the studio album over singles, EPs and compilations when a song
  exists on several releases, including when the master also has the
  single at the slave's exact folder.
- Ignore release labels (Single Version, Remastered, Explicit, Deluxe)
  inside brackets or a trailing " - ..." part; "Clean" stays a version.
- Treat live/acoustic/remix/... album folders as different recordings;
  the strict top-folder fallback now respects this too.
- Add a last-resort library-wide search that only accepts candidates whose
  artist tag agrees with the slave file.

Linking:
- Cross-folder matches now mirror the master's path in the slave (e.g. a
  single moves into the album folder) and prune the emptied folder; a
  "keep in current folder" option preserves the old behaviour. Undo
  recreates and prunes folders accordingly.
- Operations record the match kind and reason, so undo (and promotes that
  rename the master file) restore the correct pairing instead of leaving
  the file unmatched until the next scan.

UI: rewrite the approximate matching description with Avenged Sevenfold
examples and clear safeguards, and show where linking will place a file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cdnutterandClaude Opus 5.5 committed 2026-09-22 17:25:21 -07:00
1 parent 381b804742
commit 5f895cab6a
12 files changed
+717 -128

No files matched your search

+24
View File
@@ -228,6 +228,9 @@ func TestSimilarExtensionLinkRenamesAndUndo(t *testing.T) {
if ev.read(s) != "mp3" {
t.Fatal(".mp3 not restored")
}
if m := ev.match("A/B/01 - Song.mp3"); m.Kind != store.KindExtension || m.Status != store.StatusSimilar {
t.Fatalf("undo should restore the match for review, got %s/%s", m.Status, m.Kind)
}
if _, err := os.Stat(newSlave); !errors.Is(err, os.ErrNotExist) {
t.Fatal("linked .flac should be removed on undo")
}
@@ -504,3 +507,24 @@ func TestAnyLayoutMatchesWithoutWarnings(t *testing.T) {
}
}
}
func TestPromoteRenamedMasterStaysLinked(t *testing.T) {
ev := setup(t, false)
ev.write(ev.master, "A/B/Song.mp3", "lossy")
ev.write(ev.slave, "A/B/Song.flac", "lossless")
ev.scan()
m := ev.match("A/B/Song.flac")
op, err := ev.e.Promote(ctx, m.ID, true)
if err != nil {
t.Fatal(err)
}
if got := ev.match("A/B/Song.flac"); got.Status != store.StatusLinked || got.RelMaster != "A/B/Song.flac" {
t.Fatalf("after promote the pair should be linked to the renamed master, got %s -> %q", got.Status, got.RelMaster)
}
if err := ev.e.Undo(ctx, op.ID); err != nil {
t.Fatal(err)
}
if got := ev.match("A/B/Song.flac"); got.Status != store.StatusSimilar || got.RelMaster != "A/B/Song.mp3" {
t.Fatalf("undo should restore the original match, got %s -> %q", got.Status, got.RelMaster)
}
}