diff --git a/src/buildstream/_cas/cascache.py b/src/buildstream/_cas/cascache.py index 6ffb7313d..6a4043f73 100644 --- a/src/buildstream/_cas/cascache.py +++ b/src/buildstream/_cas/cascache.py @@ -226,6 +226,11 @@ def checkout(self, dest, tree, *, can_link=False, _fetch=True): fullpath = os.path.join(dest, symlinknode.name) os.symlink(symlinknode.target, fullpath) + node_properties = directory.node_properties + if node_properties.HasField("mtime"): + mtime = utils._parse_protobuf_timestamp(node_properties.mtime) + utils._set_file_mtime(dest, mtime) + # ensure_tree(): # # Make sure all blobs referenced by the given directory tree are available diff --git a/tests/internals/storage_vdir_import.py b/tests/internals/storage_vdir_import.py index 637283e69..e3bf84ab7 100644 --- a/tests/internals/storage_vdir_import.py +++ b/tests/internals/storage_vdir_import.py @@ -76,6 +76,9 @@ def generate_import_root(rootdir, filelist): (dirnames, filename) = os.path.split(path) os.makedirs(os.path.join(rootdir, dirnames), exist_ok=True) os.symlink(content, os.path.join(rootdir, path)) + # Set deterministic mtime for all directories + for (dirpath, _, _) in os.walk(rootdir): + _set_file_mtime(dirpath, MTIME) def generate_random_root(rootno, directory): @@ -116,6 +119,9 @@ def generate_random_root(rootno, directory): relative_link = os.path.relpath(symlink_destination, start=location) os.symlink(relative_link, target) things.append(os.path.join(location, thingname)) + # Set deterministic mtime for all directories + for (dirpath, _, _) in os.walk(rootdir): + _set_file_mtime(dirpath, MTIME) def file_contents(path):