mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-24 14:42:11 -03:00
refactor: simplify symlink cache invalidation by removing background rescan and noise_mtime in favor of a root-path-only fingerprint.
This commit is contained in:
@@ -63,7 +63,6 @@ def test_symlink_scan_skips_file_links(monkeypatch: pytest.MonkeyPatch, tmp_path
|
||||
|
||||
def test_symlink_cache_reuses_previous_scan(monkeypatch: pytest.MonkeyPatch, tmp_path):
|
||||
loras_dir, settings_dir = _setup_paths(monkeypatch, tmp_path)
|
||||
monkeypatch.setattr(config_module.Config, "_schedule_symlink_rescan", lambda self: None)
|
||||
|
||||
target_dir = loras_dir / "target"
|
||||
target_dir.mkdir()
|
||||
@@ -87,7 +86,6 @@ def test_symlink_cache_reuses_previous_scan(monkeypatch: pytest.MonkeyPatch, tmp
|
||||
|
||||
def test_symlink_cache_survives_noise_mtime(monkeypatch: pytest.MonkeyPatch, tmp_path):
|
||||
loras_dir, settings_dir = _setup_paths(monkeypatch, tmp_path)
|
||||
monkeypatch.setattr(config_module.Config, "_schedule_symlink_rescan", lambda self: None)
|
||||
|
||||
target_dir = loras_dir / "target"
|
||||
target_dir.mkdir()
|
||||
@@ -114,7 +112,7 @@ def test_symlink_cache_survives_noise_mtime(monkeypatch: pytest.MonkeyPatch, tmp
|
||||
assert second_cfg.map_path_to_link(str(target_dir)) == _normalize(str(dir_link))
|
||||
|
||||
|
||||
def test_background_rescan_refreshes_cache(monkeypatch: pytest.MonkeyPatch, tmp_path):
|
||||
def test_manual_rescan_refreshes_cache(monkeypatch: pytest.MonkeyPatch, tmp_path):
|
||||
loras_dir, _ = _setup_paths(monkeypatch, tmp_path)
|
||||
|
||||
target_dir = loras_dir / "target"
|
||||
@@ -135,12 +133,11 @@ def test_background_rescan_refreshes_cache(monkeypatch: pytest.MonkeyPatch, tmp_
|
||||
|
||||
second_cfg = config_module.Config()
|
||||
|
||||
# Cache may still point at the old real path immediately after load
|
||||
initial_mapping = second_cfg.map_path_to_link(str(new_target))
|
||||
assert initial_mapping in {str(new_target), _normalize(str(dir_link))}
|
||||
# Cache still point at the old real path immediately after load
|
||||
assert second_cfg.map_path_to_link(str(new_target)) == _normalize(str(new_target))
|
||||
|
||||
# Background rescan should refresh the mapping to the new target and update the cache file
|
||||
second_cfg._wait_for_rescan(timeout=2.0)
|
||||
# Manual rescan should refresh the mapping to the new target
|
||||
second_cfg.rebuild_symlink_cache()
|
||||
new_real = _normalize(os.path.realpath(new_target))
|
||||
assert second_cfg._path_mappings.get(new_real) == _normalize(str(dir_link))
|
||||
assert second_cfg.map_path_to_link(str(new_target)) == _normalize(str(dir_link))
|
||||
@@ -170,7 +167,6 @@ def test_symlink_roots_are_preserved(monkeypatch: pytest.MonkeyPatch, tmp_path):
|
||||
monkeypatch.setattr(config_module.folder_paths, "get_folder_paths", fake_get_folder_paths)
|
||||
monkeypatch.setattr(config_module, "standalone_mode", True)
|
||||
monkeypatch.setattr(config_module, "get_settings_dir", lambda create=True: str(settings_dir))
|
||||
monkeypatch.setattr(config_module.Config, "_schedule_symlink_rescan", lambda self: None)
|
||||
|
||||
cfg = config_module.Config()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user