Repository navigation
Conversation
…wins A media server's path_mapping held one from:to pair. A server that mounts each library under its own root (/media/tv as /data/tv, /media/movies as /data/films) could only be mapped for one of them, and since the partial scan from Abrechen2#219 needs the mapped folder inside a library root, every subtitle for the other library fell back to a full scan of it. A second pair was not parsed either: it became part of to_path, so the first pair broke too. apply_path_mapping now splits on ";", the list separator SUBLARR_PATH_MAPPING already uses, keeps ":" within a pair so every existing config means what it did, and applies the pair whose from_path is the longest prefix of the file, so a specific pair wins in any order. All four media server backends use it, and their help text and the UI strings say how to enter several.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #223.
Summary
path_mappingnow takes severalfrom:topairs separated by;, and the pair whosefrom_pathis the longest prefix of the file is applied./media/tvas/data/tv,/media/moviesas/data/films) could be mapped for one library only, so every subtitle for the other ended in a full scan of it. A second pair was not parsed either: it became part ofto_pathand broke the first pair too.:stays the separator within a pair, so no existing config changes meaning.MediaServer.apply_path_mapping, so Plex, Jellyfin, Kodi and Shoko all get it. Their field help text, the en/de UI strings and the CHANGELOG say how to enter several pairs.Test plan
tests/test_media_server_path_mapping.py: 10 cases, failing onmasterand passing with the change.master: same failures, plus the 10 new passes.ruff checkandruff format --checkon the changed files.mypy: no errors inmediaserver/base.py. The repo-wide errors, including the ones inplex.pyandkodi.py, are on lines this PR does not touch (CI runs it withcontinue-on-error).Evidence
The new tests on
master(47a2b65f), patch removed: 6 fail, and the 4 that pass are the controls that must not change (single pair, no mapping, no match).The first line is the reported failure: with two pairs, a TV episode maps to
/data/tv;/media/movies:/data/films/Show/ep.mkv, which no library contains.With the change:
Backend suite,
pytest --tb=no -q -n 8, Python 3.12.15, in the 1.16.0 image plusrequirements-dev.txt, run as a non-root user:masterThe same 9 tests fail on both sides and none are in code this PR touches: 6 in
tests/performance(which CI ignores),test_media_dir_temp_writers.py::test_diff_apply_keeps_sidecar_readableand the twotest_track_resync_provenance.py::test_every_sync_writer_keeps_a_download_genuineffsubsync cases.Lint:
Live, against a real Plex Media Server 1.43.4 whose libraries are mounted separately (Sublarr sees
<root>/TVand<root>/Movies, Plex sees/data/tvand/data/movies). This branch'sbackend/ran in the 1.16.0 image, withpath_mapping<root>/TV:/data/tv;<root>/Movies:/data/movies, callingPlexServer.refresh_itemfor a real movie file:Plex's log for the same call, a partial scan of that one folder and no full refresh:
On 1.16.0 with only the TV pair possible, the same movie ends in
section.update()on the whole Movies library.