Drop Artist/Album/Title depth assumptions from layout checks

Matching has always been by relative path, so any folder layout works as
long as both libraries use the same one. Remove the depth and loose-root-file
warnings, which flagged valid layouts, and reword the UI and README to say
"same folder layout on both sides" with Artist/Album/Title.ext only as an
example. The "elsewhere" fallback is now described as same top-level folder,
different subfolder. Add a test covering flat and deeply nested layouts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cdnutterandClaude Opus 5.5 committed 2026-09-22 16:48:55 -07:00
1 parent f49274360b
commit 75e0516434
9 files changed
+52 -33

No files matched your search

+9 -10
View File
@@ -293,9 +293,11 @@ func (e *Engine) NormalizePair(p *store.Pair) ([]string, error) {
}
// layoutWarnings does a cheap top-level comparison of the two libraries.
// Any folder layout works; what matters is that both libraries use the same
// one, so matching files sit at the same relative path.
func layoutWarnings(l *libs) []string {
var warns []string
list := func(root string) (dirs map[string]bool, looseFiles int) {
list := func(root string) (dirs map[string]bool, files int) {
dirs = map[string]bool{}
ents, _ := os.ReadDir(root)
for _, en := range ents {
@@ -305,20 +307,17 @@ func layoutWarnings(l *libs) []string {
if en.IsDir() {
dirs[strings.ToLower(en.Name())] = true
} else if l.hasExt(en.Name()) {
looseFiles++
files++
}
}
return
}
hd, hl := list(l.host.Path)
sd, sl := list(l.slave.Path)
if len(sd) == 0 && sl == 0 {
hd, _ := list(l.host.Path)
sd, sf := list(l.slave.Path)
if len(sd) == 0 && sf == 0 {
warns = append(warns, "The slave library is empty. Use Build to pick songs from the host library to hardlink into it.")
return warns
}
if hl > 0 || sl > 0 {
warns = append(warns, fmt.Sprintf("Found audio files directly in a library root (host: %d, slave: %d). Both libraries should use Artist/Album/Title.ext.", hl, sl))
}
shared := 0
for d := range sd {
if hd[d] {
@@ -326,8 +325,8 @@ func layoutWarnings(l *libs) []string {
}
}
if len(sd) > 0 && shared*2 < len(sd) {
warns = append(warns, fmt.Sprintf("Only %d of %d artist folders in the slave library also exist in the host library. "+
"The two libraries should share the same Artist/Album/Title.ext layout, or most files will not match.", shared, len(sd)))
warns = append(warns, fmt.Sprintf("Only %d of %d top-level folders in the slave library also exist in the host library. "+
"Both libraries should use the same folder layout, or most files will not match.", shared, len(sd)))
}
return warns
}