video: fully decouple video server from music (no fallback + hard save guard)

Two real coupling bugs, fixed:
- resolve_video_server still fell back to the music active server when no explicit
  video pick was set, so changing the music server changed video. Removed: video
  now uses ONLY an explicit video pick or the configured server(s) (Plex default
  when both). Changing the music server never changes video.
- The shared settings page could persist active_media_server from the video side.
  Guarded saveSettings itself (not just the debounced auto-save) so it NEVER runs
  while data-side=video — video saves only via /api/video/*.

Test: video does not follow the music active server. One-way isolation, both ways.
This commit is contained in:
BoulderBadgeDad 2026-06-15 14:52:37 -07:00
parent a4d6e78bce
commit 5f1ad517c2
3 changed files with 19 additions and 7 deletions

View file

@ -92,12 +92,10 @@ def resolve_video_server(db=None):
return "plex"
if pref == "jellyfin" and jelly_ok:
return "jellyfin"
active = config_manager.get_active_media_server()
if active == "plex" and plex_ok:
return "plex"
if active == "jellyfin" and jelly_ok:
return "jellyfin"
# Fully INDEPENDENT of the music 'active server' — only an explicit video pick
# or the configured server(s) decide, so changing the music server NEVER
# changes video (and vice-versa). Auto-pick the single configured one; default
# to Plex when both are set (the user picks Jellyfin via the Video Source panel).
if plex_ok and not jelly_ok:
return "plex"
if jelly_ok and not plex_ok:

View file

@ -47,6 +47,15 @@ def test_independent_of_music_active(monkeypatch, vdb):
def test_both_configured_default_then_explicit_pick(monkeypatch, vdb):
_set_cm(monkeypatch, True, True, "plex")
assert resolve_video_server(vdb) == "plex" # falls back to the active one
assert resolve_video_server(vdb) == "plex" # both → Plex default
vdb.set_setting("video_server", "jellyfin")
assert resolve_video_server(vdb) == "jellyfin" # explicit video pick wins
def test_does_not_follow_music_active_server(monkeypatch, vdb):
# Both configured + music set to Jellyfin, but NO explicit video pick → video
# stays on Plex. Changing the music server must never change video.
_set_cm(monkeypatch, True, True, "jellyfin")
assert resolve_video_server(vdb) == "plex"
vdb.set_setting("video_server", "jellyfin") # only an explicit pick switches video
assert resolve_video_server(vdb) == "jellyfin"

View file

@ -2867,6 +2867,11 @@ function _getTagConfig(path) {
}
async function saveSettings(quiet = false) {
// ISOLATION: this saves MUSIC settings (and persists active_media_server from
// the shared server toggle). The video side reuses this page but must never
// write music config — it saves via /api/video/* only. So never run here while
// on the video side, no matter what triggered it (auto-save OR manual).
if (document.body.getAttribute('data-side') === 'video') return;
// Validate file organization templates before saving
const validationErrors = validateFileOrganizationTemplates();
if (validationErrors.length > 0) {