You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by gi...@apache.org on 2020/12/29 13:05:25 UTC

[buildstream] 08/26: cascache: parse timestamp and update mtimes in checkout

This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch traveltissues/mr4
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 0d1b6d057a32236540fc2d006bdfd60199a8ce1e
Author: Darius Makovsky <tr...@protonmail.com>
AuthorDate: Wed Jan 8 16:30:59 2020 +0000

    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.
---
 src/buildstream/_cas/cascache.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/buildstream/_cas/cascache.py b/src/buildstream/_cas/cascache.py
index 519de6e..c608f12 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:
+                    # XXX: 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(