summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarius Makovsky <traveltissues@protonmail.com>2020-01-08 16:30:59 +0000
committerJürg Billeter <j@bitron.ch>2020-02-04 10:51:44 +0100
commit13e498f84e7a158c7e858719dec64281513f81e5 (patch)
tree6bcd7e7bcf1cc05d2faa73f6c204f64dc5f9adc2
parentb80368566872ce45085dea68e375dc5f37fafbcf (diff)
downloadbuildstream-13e498f84e7a158c7e858719dec64281513f81e5.tar.gz
cascache: parse timestamp and update mtimes in checkout
If checking out files from a CasBasedDirectory which holds node_properties in the index files are explicitly copied instead of being hardlinked and the mtime is updated to the stored value.
-rw-r--r--src/buildstream/_cas/cascache.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/buildstream/_cas/cascache.py b/src/buildstream/_cas/cascache.py
index 519de6e2e..bb2abc6c8 100644
--- a/src/buildstream/_cas/cascache.py
+++ b/src/buildstream/_cas/cascache.py
@@ -217,10 +217,18 @@ class CASCache:
for filenode in directory.files:
# regular file, create hardlink
fullpath = os.path.join(dest, filenode.name)
- if can_link:
+ # generally, if the node holds properties we will fallback
+ # to copying instead of hardlinking
+ if can_link and not filenode.node_properties:
utils.safe_link(self.objpath(filenode.digest), fullpath)
else:
utils.safe_copy(self.objpath(filenode.digest), fullpath)
+ if filenode.node_properties:
+ # see https://github.com/bazelbuild/remote-apis/blob/master/build/bazel/remote/execution/v2/nodeproperties.md
+ # for supported node property specifications
+ for prop in filenode.node_properties:
+ if prop.name == "MTime" and prop.value:
+ utils._set_file_mtime(fullpath, utils._parse_timestamp(prop.value))
if filenode.is_executable:
os.chmod(