v0.12.1: stop asking where the music is when config.json already says

Restarting on the machine that mounts the drive at /media/trav/muzak opened
"LinTunes can't find your music folder", offering ~/Music. The library's only
music_folder is the other machine's mount point (/run/media/trav/tummult/...)
because this library predates 0.10 and has no music_folder_rel yet — but
config.json has held the right path all along under music_root, which
`--music-root … --save-config` writes and the importer stores as
library.music_folder. resolve() only looked for music_folder_override, a key
that exists solely because the prompt writes it, so a library imported the
normal way could never satisfy the check that decides whether to prompt.

music_root is now a machine-local candidate alongside music_folder_override,
consulted in the same last-resort position and subject to the same must-exist
rule, so a stale one still reports "missing" rather than resolving to a phantom
tree. Read-only: nothing writes it back, and the newer key still wins when both
are present.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y9ZEFi4qNJ39FMiBtiAxy2
This commit is contained in:
2026-08-25 15:06:13 -04:00
co-authored by Claude Opus 5
parent 521db2f81d
commit 7df5ecf868
4 changed files with 59 additions and 5 deletions
+40
View File
@@ -241,6 +241,46 @@ class TestMusicFolderResolution:
assert state.path == elsewhere
assert state.source == "machine"
def test_the_pre_010_music_root_key_counts_as_an_override(
self, tmp_path, isolated_config):
"""`--music-root … --save-config` has always written this machine's
media folder to config.json as `music_root`. Every library imported that
way already knows where its music is here, so a machine that mounts the
drive at a different path must not be asked to go find it."""
from lintunes.config import save_config
media = tmp_path / "media"
media.mkdir()
save_config({"music_root": str(media)})
# The shared value is another machine's mount point, unreachable here.
gone = Library(music_folder="/run/media/trav/tummult/music/iTunes Media")
state = music_folder.resolve(gone, tmp_path)
assert state.path == media
assert state.source == "machine"
def test_the_newer_override_key_still_wins(self, tmp_path, isolated_config):
from lintunes.config import save_config
chosen, imported = tmp_path / "chosen", tmp_path / "imported"
chosen.mkdir()
imported.mkdir()
save_config({"music_folder_override": str(chosen),
"music_root": str(imported)})
state = music_folder.resolve(Library(music_folder="/nope"), tmp_path)
assert state.path == chosen
def test_a_stale_music_root_does_not_resolve(self, tmp_path, isolated_config):
"""It's still a candidate, not an answer — the folder has to be there."""
from lintunes.config import save_config
save_config({"music_root": str(tmp_path / "unplugged")})
state = music_folder.resolve(Library(music_folder="/nope"), tmp_path)
assert state.path is None
assert state.source == "missing"
def test_unset_and_missing_are_different_conversations(self, tmp_path,
isolated_config):
assert music_folder.resolve(Library(), tmp_path).source == "unset"