diff options
author | Tristan Maat <tristan.maat@codethink.co.uk> | 2019-12-17 14:11:36 +0000 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2020-02-05 17:14:28 +0000 |
commit | d528fd80b418ce3f58a7bf3c13da5db448494df8 (patch) | |
tree | 355c0a45ed767b6e5a9f18b64f71b76a53bd03a4 /src | |
parent | 067ea76296a84620d2147dabdf1f3d0699c810d0 (diff) | |
download | buildstream-d528fd80b418ce3f58a7bf3c13da5db448494df8.tar.gz |
_casbaseddirectory.py: Refactor _add_file
For some reason we were directly modifying fields on the object
although they can be set comfortably using the constructor.
Diffstat (limited to 'src')
-rw-r--r-- | src/buildstream/storage/_casbaseddirectory.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/buildstream/storage/_casbaseddirectory.py b/src/buildstream/storage/_casbaseddirectory.py index 624d071dd..04b2a61ca 100644 --- a/src/buildstream/storage/_casbaseddirectory.py +++ b/src/buildstream/storage/_casbaseddirectory.py @@ -158,19 +158,26 @@ class CasBasedDirectory(Directory): return newdir def _add_file(self, basename, filename, modified=False, can_link=False, properties=None): - entry = IndexEntry(filename, _FileType.REGULAR_FILE, modified=modified or filename in self.index) path = os.path.join(basename, filename) - entry.digest = self.cas_cache.add_object(path=path, link_directly=can_link) - entry.is_executable = os.access(path, os.X_OK) - properties = properties or [] + digest = self.cas_cache.add_object(path=path, link_directly=can_link) + is_executable = os.access(path, os.X_OK) + node_properties = [] # see https://github.com/bazelbuild/remote-apis/blob/master/build/bazel/remote/execution/v2/nodeproperties.md # for supported node property specifications - entry.node_properties = [] - if "MTime" in properties: + if properties and "MTime" in properties: node_property = remote_execution_pb2.NodeProperty() node_property.name = "MTime" node_property.value = _get_file_mtimestamp(path) - entry.node_properties.append(node_property) + node_properties.append(node_property) + + entry = IndexEntry( + filename, + _FileType.REGULAR_FILE, + digest=digest, + is_executable=is_executable, + modified=modified or filename in self.index, + node_properties=node_properties, + ) self.index[filename] = entry self.__invalidate_digest() |