Skip to content

Commit 922b150

Browse files
authored
Merge pull request #2001 from apache/juerg/directory-mtime
Support directory mtime to fix tests with recent buildbox-casd
2 parents a3e280a + 8c45f26 commit 922b150

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/buildstream/_cas/cascache.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@ def checkout(self, dest, tree, *, can_link=False, _fetch=True):
226226
fullpath = os.path.join(dest, symlinknode.name)
227227
os.symlink(symlinknode.target, fullpath)
228228

229+
node_properties = directory.node_properties
230+
if node_properties.HasField("mtime"):
231+
mtime = utils._parse_protobuf_timestamp(node_properties.mtime)
232+
utils._set_file_mtime(dest, mtime)
233+
229234
# ensure_tree():
230235
#
231236
# Make sure all blobs referenced by the given directory tree are available

tests/internals/storage_vdir_import.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def generate_import_root(rootdir, filelist):
7676
(dirnames, filename) = os.path.split(path)
7777
os.makedirs(os.path.join(rootdir, dirnames), exist_ok=True)
7878
os.symlink(content, os.path.join(rootdir, path))
79+
# Set deterministic mtime for all directories
80+
for (dirpath, _, _) in os.walk(rootdir):
81+
_set_file_mtime(dirpath, MTIME)
7982

8083

8184
def generate_random_root(rootno, directory):
@@ -116,6 +119,9 @@ def generate_random_root(rootno, directory):
116119
relative_link = os.path.relpath(symlink_destination, start=location)
117120
os.symlink(relative_link, target)
118121
things.append(os.path.join(location, thingname))
122+
# Set deterministic mtime for all directories
123+
for (dirpath, _, _) in os.walk(rootdir):
124+
_set_file_mtime(dirpath, MTIME)
119125

120126

121127
def file_contents(path):

0 commit comments

Comments
 (0)