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

juergbi pushed a commit to branch juerg/remote-cache-ci
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit e5cf255cf89439c7ae8cef725e522a2829e7036c
Author: Jürg Billeter <[email protected]>
AuthorDate: Thu Sep 10 19:14:50 2020 +0200

    _artifact.py: Add cached and strong_key parameters to set_cached()
---
 src/buildstream/_artifact.py | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/buildstream/_artifact.py b/src/buildstream/_artifact.py
index 28e2f59..51e1f57 100644
--- a/src/buildstream/_artifact.py
+++ b/src/buildstream/_artifact.py
@@ -616,10 +616,20 @@ class Artifact:
     # Mark the artifact as cached without querying the filesystem.
     # This is used as optimization when we know the artifact is available.
     #
-    def set_cached(self):
-        self._proto = self._load_proto()
-        assert self._proto
-        self._cached = True
+    def set_cached(self, cached=True, *, strong_key=None):
+        if strong_key:
+            assert not self._cache_key or self._cache_key == strong_key
+            self._cache_key = strong_key
+
+        if cached:
+            self._proto = self._load_proto()
+            assert self._proto
+            if self._cache_key:
+                assert self._cache_key == self._proto.strong_key
+            else:
+                self._cache_key = self._proto.strong_key
+
+        self._cached = cached
 
     # pull()
     #

Reply via email to