feat: show real on-disk tracklist in the Library album modal (#9)
The Library modal showed MusicBrainz's canonical tracklist, hiding incomplete downloads / edition or track-order mismatches, and showed nothing for albums without an rgMbid. Now it shows the REAL files on disk. - LibraryItem gains trackNames String[] (migration add_library_track_names): the album's on-disk "## Title.ext" audio filenames. - Captured at import (pipeline._import lists the final album folder) and at scan (scan._record_owned now also refreshes trackNames on re-scan via ON CONFLICT DO UPDATE + xmax=0 to preserve the newly-imported flag). New shared library.list_audio_files() helper. - /api/library exposes trackNames; the AlbumModal prefers on-disk tracks when present (parsed "## Title" → position/title, zero network, labeled "On disk · N tracks"), falling back to the MusicBrainz listing otherwise. Items imported before this column show the MB fallback until re-scanned. worker 221 tests / 7-skip, web 153, tsc + build clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
from lyra_worker.library import list_audio_files
|
||||
|
||||
|
||||
def test_lists_sorted_audio_basenames_only(tmp_path):
|
||||
(tmp_path / "02 Two.flac").write_bytes(b"")
|
||||
(tmp_path / "01 One.flac").write_bytes(b"")
|
||||
(tmp_path / "10 Ten.mp3").write_bytes(b"")
|
||||
(tmp_path / "cover.jpg").write_bytes(b"") # non-audio excluded
|
||||
(tmp_path / "notes.txt").write_bytes(b"") # non-audio excluded
|
||||
(tmp_path / "Disc 1").mkdir() # a subdir is not a file
|
||||
|
||||
assert list_audio_files(str(tmp_path)) == ["01 One.flac", "02 Two.flac", "10 Ten.mp3"]
|
||||
|
||||
|
||||
def test_missing_dir_returns_empty():
|
||||
assert list_audio_files("/no/such/album/dir") == []
|
||||
|
||||
|
||||
def test_empty_dir_returns_empty(tmp_path):
|
||||
assert list_audio_files(str(tmp_path)) == []
|
||||
Reference in New Issue
Block a user