summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/buildstream/_assetcache.py9
-rw-r--r--tests/frontend/artifact_list_contents.py2
2 files changed, 8 insertions, 3 deletions
diff --git a/src/buildstream/_assetcache.py b/src/buildstream/_assetcache.py
index 68f7fd732..a0b502f2b 100644
--- a/src/buildstream/_assetcache.py
+++ b/src/buildstream/_assetcache.py
@@ -17,7 +17,7 @@
# Raoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk>
#
import os
-from fnmatch import fnmatch
+import re
from itertools import chain
from typing import TYPE_CHECKING
import grpc
@@ -630,11 +630,16 @@ class AssetCache:
# append the glob to optimise the os.walk()
path = os.path.join(base_path, globdir)
+ regexer = None
+ if glob_expr:
+ expression = utils._glob2re(glob_expr)
+ regexer = re.compile(expression)
+
for root, _, files in os.walk(path):
for filename in files:
ref_path = os.path.join(root, filename)
relative_path = os.path.relpath(ref_path, base_path) # Relative to refs head
- if not glob_expr or fnmatch(relative_path, glob_expr):
+ if regexer is None or regexer.match(relative_path):
# Obtain the mtime (the time a file was last modified)
yield (os.path.getmtime(ref_path), relative_path)
diff --git a/tests/frontend/artifact_list_contents.py b/tests/frontend/artifact_list_contents.py
index 8bd7bdeff..ee129cc9f 100644
--- a/tests/frontend/artifact_list_contents.py
+++ b/tests/frontend/artifact_list_contents.py
@@ -71,7 +71,7 @@ def test_artifact_list_exact_contents_glob(cli, datafiles):
assert result.exit_code == 0
# List the contents via glob
- result = cli.run(project=project, args=["artifact", "list-contents", "test/*"])
+ result = cli.run(project=project, args=["artifact", "list-contents", "test/**"])
assert result.exit_code == 0
# get the cahe keys for each element in the glob