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. Claude-Session: https://claude.ai/code/session_01Y9ZEFi4qNJ39FMiBtiAxy2
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
"""LinTunes — iTunes-style music library manager and player for Linux."""
|
||||
|
||||
__version__ = "0.12.0"
|
||||
__version__ = "0.12.1"
|
||||
|
||||
@@ -10,7 +10,9 @@ single place that decides, in this order:
|
||||
machine even when the absolute paths are not.
|
||||
2. ``music_folder`` — the legacy absolute value. Libraries written before 0.10,
|
||||
and libraries last written by an older LinTunes, only have this one.
|
||||
3. The machine-local override in ``~/.config/lintunes/config.json``.
|
||||
3. The machine-local override in ``~/.config/lintunes/config.json`` — either
|
||||
``music_folder_override`` (set by the folder prompt) or the older
|
||||
``music_root`` that ``--music-root … --save-config`` has always written.
|
||||
|
||||
The override is consulted **last, not first**, on purpose. If it won outright, a
|
||||
machine that once needed an override would be pinned to it forever and would
|
||||
@@ -32,6 +34,13 @@ from lintunes.paths import to_absolute
|
||||
# Keys in the per-machine config.json (never synced).
|
||||
OVERRIDE_KEY = "music_folder_override"
|
||||
PROMPT_SEEN_KEY = "music_folder_prompted"
|
||||
# The same fact under its pre-0.10 name: `--music-root … --save-config` has
|
||||
# always written this machine's media folder here, and the importer stores it as
|
||||
# `library.music_folder`. Every library set up that way therefore has the right
|
||||
# answer sitting in config.json, and ignoring it meant a machine that mounts the
|
||||
# drive somewhere else was asked to locate a folder it had already been told
|
||||
# about. Read-only — nothing writes it back, so the newer key stays canonical.
|
||||
LEGACY_OVERRIDE_KEY = "music_root"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -73,8 +82,10 @@ def resolve(library, data_dir, config=None) -> Resolution:
|
||||
if found is not None:
|
||||
return Resolution(found, "legacy", legacy)
|
||||
|
||||
override = config.get(OVERRIDE_KEY, "")
|
||||
if override:
|
||||
for key in (OVERRIDE_KEY, LEGACY_OVERRIDE_KEY):
|
||||
override = config.get(key, "")
|
||||
if not override:
|
||||
continue
|
||||
found = _existing_dir(override)
|
||||
if found is not None:
|
||||
return Resolution(found, "machine", override)
|
||||
|
||||
Reference in New Issue
Block a user