fix: scan records the probed format + skips hidden album dirs (probe once)

Probe each album exactly once and thread the ProbeResult through for
tags, quality, and format instead of hardcoding LibraryItem.format to
"FLAC" and re-probing on the tag-fallback path. Also skip album-level
directories starting with "." (previously only artist-level dirs were
skipped).
This commit is contained in:
Jonathan
2026-07-11 17:06:48 +02:00
parent 4907d0d5a4
commit 4da0db4a1d
2 changed files with 26 additions and 6 deletions
+21
View File
@@ -96,3 +96,24 @@ def test_scan_is_idempotent(conn, tmp_path):
second = scan_library(conn, resolver, FakeProbe(quality_class=3), dest_root=str(tmp_path))
assert second.imported == 0 # already recorded
assert _counts(conn) == {"LibraryItem": 1, "MonitoredRelease": 1, "WatchedArtist": 1}
def test_scan_records_the_probed_format(conn, tmp_path):
_album(tmp_path, "John Mayer", "Sob Rock (2021)")
resolver = FakeResolver({
("John Mayer", "Sob Rock"): MBTarget(
artist="John Mayer", album="Sob Rock", year=2021, rg_mbid="rg2", artist_mbid="a1"),
})
scan_library(conn, resolver, FakeProbe(fmt="MP3", quality_class=1), dest_root=str(tmp_path))
with conn.cursor() as cur:
cur.execute('SELECT format, "qualityClass" FROM "LibraryItem" WHERE album=%s', ("Sob Rock",))
assert cur.fetchone() == ("MP3", 1) # the probed format is recorded, not a hardcoded FLAC
def test_scan_skips_hidden_album_dirs(conn, tmp_path):
hidden = tmp_path / "John Mayer" / ".sync"
hidden.mkdir(parents=True)
(hidden / "01 Track.flac").write_bytes(b"")
result = scan_library(conn, FakeResolver({}), FakeProbe(), dest_root=str(tmp_path))
assert (result.imported, result.skipped) == (0, 0) # hidden album dir not scanned
assert _counts(conn) == {"LibraryItem": 0, "MonitoredRelease": 0, "WatchedArtist": 0}