mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-09-21 03:01:27 -03:00
feat(backend): gate Other Models behind opt-in management toggles
Other Models management is now opt-in: enable_other_models (default false) plus the enabled_other_sub_types allow-list replace the unreleased additive enabled_other_folders key. - config._get_enabled_other_folder_keys() is the single scan gate; a new refresh_other_roots() rebuilds roots and preview roots on toggle. - ModelScanner gains a _should_keep_cached_entry() hydration hook and on_library_changed(reconcile=...) so switching a sub_type off drops its entries (and hash/autov3 rows) at load time and switching it on rescans. - OtherScanner filters location-derived entries accordingly. - Other routes reject every other type while off (or a disabled sub_type) and expose an "other_disabled" page flag; download routing returns a disabled marker instead of guessing; the download manager refuses other-type downloads and default-path routing for switched-off sub_types. - Doctor / init-status / refresh-all skip the other scanner while off; the scanner stays registered so staged pending-deletes still merge. - Tests updated with explicit opt-in fixtures plus new gating coverage.
This commit is contained in:
@@ -30,6 +30,20 @@ def routes():
|
||||
return handler
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def enable_other_models():
|
||||
"""Other Models is opt-in; these tests exercise the enabled state."""
|
||||
from py.services.settings_manager import get_settings_manager
|
||||
|
||||
manager = get_settings_manager()
|
||||
manager.set("enable_other_models", True)
|
||||
manager.set(
|
||||
"enabled_other_sub_types",
|
||||
["vae", "upscaler", "text_encoder", "clip_vision", "controlnet"],
|
||||
)
|
||||
yield
|
||||
|
||||
|
||||
def test_common_and_specific_routes_registered():
|
||||
"""Registration smoke test: /api/lm/other/* surface plus the /other page."""
|
||||
app = web.Application()
|
||||
@@ -64,6 +78,39 @@ def test_validate_civitai_model_type_rejects_foreign_types(model_type):
|
||||
assert OtherRoutes()._validate_civitai_model_type(model_type) is False
|
||||
|
||||
|
||||
def test_validate_rejects_everything_when_feature_disabled():
|
||||
from py.services.settings_manager import get_settings_manager
|
||||
|
||||
get_settings_manager().set("enable_other_models", False)
|
||||
|
||||
handler = OtherRoutes()
|
||||
for model_type in ("VAE", "Upscaler", "TextEncoder", "CLIPVision", "Other"):
|
||||
assert handler._validate_civitai_model_type(model_type) is False
|
||||
|
||||
|
||||
def test_validate_rejects_switched_off_sub_type():
|
||||
from py.services.settings_manager import get_settings_manager
|
||||
|
||||
get_settings_manager().set("enabled_other_sub_types", ["vae"])
|
||||
|
||||
handler = OtherRoutes()
|
||||
assert handler._validate_civitai_model_type("VAE") is True
|
||||
assert handler._validate_civitai_model_type("Upscaler") is False
|
||||
|
||||
|
||||
def test_page_context_reports_feature_state():
|
||||
from py.services.settings_manager import get_settings_manager
|
||||
|
||||
manager = get_settings_manager()
|
||||
handler = OtherRoutes()
|
||||
provider = handler._get_page_context_provider()
|
||||
|
||||
assert provider(None) == {"other_disabled": False}
|
||||
|
||||
manager.set("enable_other_models", False)
|
||||
assert provider(None) == {"other_disabled": True}
|
||||
|
||||
|
||||
def test_get_expected_model_types_mentions_supported_types():
|
||||
expected = OtherRoutes()._get_expected_model_types()
|
||||
for name in ("VAE", "Upscaler", "TextEncoder", "CLIPVision", "Controlnet"):
|
||||
|
||||
Reference in New Issue
Block a user