diff --git a/swh/model/from_disk.py b/swh/model/from_disk.py --- a/swh/model/from_disk.py +++ b/swh/model/from_disk.py @@ -300,16 +300,17 @@ Args: root_path (bytes): path to the root directory - patterns (list of byte): patterns to match + patterns (list of byte): shell patterns to match Yields: an SRE_Pattern object """ absolute_root_path = os.path.abspath(root_path) for pattern in patterns: - for path in glob.glob(pattern): - absolute_path = os.path.abspath(path) - if not absolute_path.startswith(absolute_root_path): + if os.path.isabs(pattern): + pattern = os.path.relpath(pattern, root_path) + for path in glob.glob(pattern, root_dir=absolute_root_path): + if os.path.isabs(path) and not path.startswith(absolute_root_path): error_msg = ( b'The path "' + path + b'" is not a subdirectory or relative ' b'to the root directory path: "' + root_path + b'"'