diff --git a/engine/artifact_manager.py b/engine/artifact_manager.py index e344cd1..59caa72 100644 --- a/engine/artifact_manager.py +++ b/engine/artifact_manager.py @@ -23,14 +23,16 @@ class ArtifactManager: normalized_pattern = pattern.replace("\\", "/") segments = [segment for segment in normalized_pattern.split("/") if segment and segment != "."] prefix: list[str] = [] + saw_glob = False for segment in segments: if any(char in segment for char in "*?["): + saw_glob = True break prefix.append(segment) - if prefix: - roots.append(root_dir.joinpath(*prefix)) - continue - roots.append(root_dir) + candidate = root_dir.joinpath(*prefix) if prefix else root_dir + if prefix and not saw_glob and (not candidate.exists() or candidate.is_file()): + candidate = candidate.parent + roots.append(candidate) minimal_roots: list[Path] = [] for root in sorted(set(roots), key=lambda candidate: (len(candidate.parts), candidate.as_posix())): if any(existing == root or existing in root.parents for existing in minimal_roots):