From 6b3a11e01a4ed172859f3851131dc6adde9fde2e Mon Sep 17 00:00:00 2001 From: Will Miao Date: Tue, 9 Dec 2025 21:46:33 +0800 Subject: [PATCH] fix(config): ensure symlink mappings are recorded before duplicate check Update symlink traversal logic to always record path mappings before checking for visited directories. This prevents valid link->target pairs from being dropped when the target directory has already been visited via another path. Also correct path mapping lookup to properly replace link paths with their actual target paths. --- py/config.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/py/config.py b/py/config.py index 27876d9f..6212c3b9 100644 --- a/py/config.py +++ b/py/config.py @@ -396,10 +396,13 @@ class Config: continue normalized_target = self._normalize_path(target_path) + # Always record the mapping even if we already visited + # the real directory via another path. This prevents the + # traversal order from dropping valid link->target pairs. + self.add_path_mapping(entry_path, target_path) if normalized_target in visited_dirs: continue visited_dirs.add(normalized_target) - self.add_path_mapping(entry_path, target_path) stack.append(target_path) continue @@ -504,9 +507,9 @@ class Config: normalized_link = os.path.normpath(link_path).replace(os.sep, '/') # Check if the path is contained in any mapped target path for target_path, link_path in self._path_mappings.items(): - if normalized_link.startswith(target_path): - # If the path starts with the target path, replace with actual path - mapped_path = normalized_link.replace(target_path, link_path, 1) + if normalized_link.startswith(link_path): + # If the path starts with the link path, replace with actual path + mapped_path = normalized_link.replace(link_path, target_path, 1) return mapped_path return link_path