mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-09-20 18:51:26 -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:
@@ -173,6 +173,51 @@ class TestOtherScannerRoots:
|
||||
assert result["sub_type"] == "upscaler"
|
||||
|
||||
|
||||
class TestOtherScannerHydrationFilter:
|
||||
"""Persisted entries for roots that are no longer managed are dropped."""
|
||||
|
||||
def test_keeps_entries_under_enabled_roots(self, other_config):
|
||||
scanner = _make_scanner()
|
||||
assert (
|
||||
scanner._should_keep_cached_entry(
|
||||
{"file_path": f"{other_config['vae']}/model.safetensors"}
|
||||
)
|
||||
is True
|
||||
)
|
||||
|
||||
def test_drops_entries_under_disabled_root(self, other_config, monkeypatch):
|
||||
scanner = _make_scanner()
|
||||
# Only vae stays managed; the upscaler root disappeared from the map.
|
||||
monkeypatch.setattr(
|
||||
config_module.config,
|
||||
"other_root_subtypes",
|
||||
{other_config["vae"]: "vae"},
|
||||
)
|
||||
|
||||
assert (
|
||||
scanner._should_keep_cached_entry(
|
||||
{"file_path": f"{other_config['upscaler']}/model.safetensors"}
|
||||
)
|
||||
is False
|
||||
)
|
||||
assert (
|
||||
scanner._should_keep_cached_entry(
|
||||
{"file_path": f"{other_config['vae']}/model.safetensors"}
|
||||
)
|
||||
is True
|
||||
)
|
||||
|
||||
def test_drops_everything_when_feature_off(self, monkeypatch):
|
||||
monkeypatch.setattr(config_module.config, "other_root_subtypes", {})
|
||||
scanner = _make_scanner()
|
||||
assert (
|
||||
scanner._should_keep_cached_entry(
|
||||
{"file_path": "/models/vae/model.safetensors"}
|
||||
)
|
||||
is False
|
||||
)
|
||||
|
||||
|
||||
class TestOtherScannerLazyHash:
|
||||
"""Lazy hashing: pending by default, singleflight on-demand calculation."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user