mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-09-22 03:24:09 -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:
@@ -5,6 +5,22 @@ import json
|
||||
import pytest
|
||||
|
||||
from py.routes.handlers.download_routing_handlers import DownloadRoutingHandler
|
||||
from py.services.settings_manager import get_settings_manager
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def enable_other_models():
|
||||
"""Other Models is opt-in; enable every sub_type for the routing tests."""
|
||||
manager = get_settings_manager()
|
||||
manager.settings["enable_other_models"] = True
|
||||
manager.settings["enabled_other_sub_types"] = [
|
||||
"vae",
|
||||
"upscaler",
|
||||
"text_encoder",
|
||||
"clip_vision",
|
||||
"controlnet",
|
||||
]
|
||||
yield
|
||||
|
||||
|
||||
class FakeRequest:
|
||||
@@ -149,3 +165,32 @@ async def test_other_invalid_selected_file_type_rejected():
|
||||
FakeRequest({"model_type": "VAE", "selected_file_type": 123})
|
||||
)
|
||||
assert response.status == 400
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_other_routing_disabled_when_feature_off():
|
||||
get_settings_manager().settings["enable_other_models"] = False
|
||||
|
||||
handler = DownloadRoutingHandler()
|
||||
response = await handler.get_download_routing(
|
||||
FakeRequest({"model_type": "VAE", "file_types": ["Model"]})
|
||||
)
|
||||
payload = json.loads(response.text)
|
||||
assert payload["sub_type"] is None
|
||||
assert payload["disabled"] is True
|
||||
assert payload["reason"] == "other_models_disabled"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_other_routing_disabled_for_switched_off_sub_type():
|
||||
get_settings_manager().settings["enabled_other_sub_types"] = ["vae"]
|
||||
|
||||
handler = DownloadRoutingHandler()
|
||||
response = await handler.get_download_routing(
|
||||
FakeRequest({"model_type": "Upscaler", "file_types": ["Model"]})
|
||||
)
|
||||
payload = json.loads(response.text)
|
||||
assert payload["sub_type"] is None
|
||||
assert payload["disabled"] is True
|
||||
assert payload["reason"] == "other_sub_type_disabled"
|
||||
assert payload["requested_sub_type"] == "upscaler"
|
||||
|
||||
Reference in New Issue
Block a user