mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-23 22:22:11 -03:00
feat(config): seed root symlink mappings before deep scanning
Add `_seed_root_symlink_mappings` method to ensure symlinked root folders are recorded before deep scanning, preventing them from being missed during directory traversal. This ensures that root symlinks are properly captured in the path mappings. Additionally, normalize separators in relative paths for cross-platform consistency in `BaseModelService`, and update tests to verify root symlinks are preserved in the cache.
This commit is contained in:
17
py/config.py
17
py/config.py
@@ -355,6 +355,7 @@ class Config:
|
||||
start = time.perf_counter()
|
||||
# Reset mappings before rescanning to avoid stale entries
|
||||
self._path_mappings.clear()
|
||||
self._seed_root_symlink_mappings()
|
||||
visited_dirs: Set[str] = set()
|
||||
for root in self._symlink_roots():
|
||||
self._scan_directory_links(root, visited_dirs)
|
||||
@@ -458,6 +459,22 @@ class Config:
|
||||
self._preview_root_paths.update(self._expand_preview_root(normalized_target))
|
||||
self._preview_root_paths.update(self._expand_preview_root(normalized_link))
|
||||
|
||||
def _seed_root_symlink_mappings(self) -> None:
|
||||
"""Ensure symlinked root folders are recorded before deep scanning."""
|
||||
|
||||
for root in self._symlink_roots():
|
||||
if not root:
|
||||
continue
|
||||
try:
|
||||
if not self._is_link(root):
|
||||
continue
|
||||
target_path = os.path.realpath(root)
|
||||
if not os.path.isdir(target_path):
|
||||
continue
|
||||
self.add_path_mapping(root, target_path)
|
||||
except Exception as exc:
|
||||
logger.debug("Skipping root symlink %s: %s", root, exc)
|
||||
|
||||
def _expand_preview_root(self, path: str) -> Set[Path]:
|
||||
"""Return normalized ``Path`` objects representing a preview root."""
|
||||
|
||||
|
||||
@@ -716,6 +716,8 @@ class BaseModelService(ABC):
|
||||
if normalized_file.startswith(normalized_root):
|
||||
# Remove root and leading separator to get relative path
|
||||
relative_path = normalized_file[len(normalized_root):].lstrip(os.sep)
|
||||
# Normalize separators so results are stable across platforms
|
||||
relative_path = relative_path.replace(os.sep, "/")
|
||||
break
|
||||
|
||||
if not relative_path:
|
||||
|
||||
Reference in New Issue
Block a user