Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2361,8 +2361,10 @@ def _pick_installed_primary_vst(rs_gear: str, known_lookup: dict) -> dict | None
for cand in candidates:
if not isinstance(cand, dict):
continue
if cand.get("bundled"):
continue
# Thin packaged builds download Rig Builder VSTs into the writable
# config root instead of _plugin_dir. _build_known_vst_lookup() scans
# both roots, so a missing read-only bundle must still fall back to its
# detected plugin name here.
if not cand.get("name") or not known_lookup:
continue
installed = known_lookup.get(cand["name"].lower())
Expand Down
63 changes: 63 additions & 0 deletions tests/test_vst_primary_resolution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
from __future__ import annotations

import importlib.util
from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]


def _routes_module():
spec = importlib.util.spec_from_file_location(
"rig_builder_routes_for_vst_primary_test", ROOT / "routes.py"
)
assert spec and spec.loader
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module


def _candidate():
return {
"name": "Chorus",
"format": "VST3",
"bundled": "vst/pedals/CH-2.vst3",
}


def test_primary_prefers_plugin_directory_bundle(tmp_path):
routes = _routes_module()
routes._plugin_dir = tmp_path / "read-only-plugin"
bundle = routes._plugin_dir / "vst" / "pedals" / "CH-2.vst3"
bundle.mkdir(parents=True)
routes._load_vst_seed_catalog = lambda: {"Pedal_Chorus": [_candidate()]}

downloaded = tmp_path / "writable-pack" / "pedals" / "Chorus.vst3"
known = {
"chorus": [
{"path": str(downloaded), "format": "VST3", "name": "Chorus"}
]
}

assert routes._pick_installed_primary_vst("Pedal_Chorus", known) == {
"vst_path": str(bundle),
"vst_format": "VST3",
}


def test_primary_falls_back_to_downloaded_pack_for_bundled_candidate(tmp_path):
routes = _routes_module()
routes._plugin_dir = tmp_path / "read-only-plugin"
routes._load_vst_seed_catalog = lambda: {"Pedal_Chorus": [_candidate()]}

downloaded = tmp_path / "writable-pack" / "pedals" / "Chorus.vst3"
known = {
"chorus": [
{"path": str(downloaded), "format": "VST3", "name": "Chorus"}
]
}

assert routes._pick_installed_primary_vst("Pedal_Chorus", known) == {
"vst_path": str(downloaded),
"vst_format": "VST3",
}