summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2020-09-10 19:14:50 +0200
committerJürg Billeter <j@bitron.ch>2020-12-14 10:41:52 +0100
commitf0c5f4a0e4e7f1636ece9c13caad231a474f388a (patch)
tree9daf1af44956d8461839ea80b7f7cf97fd534356
parentfa5e01bbb0126e112df1b69ef6ed7d3a3beaa86b (diff)
downloadbuildstream-f0c5f4a0e4e7f1636ece9c13caad231a474f388a.tar.gz
_artifact.py: Add cached and strong_key parameters to set_cached()
-rw-r--r--src/buildstream/_artifact.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/buildstream/_artifact.py b/src/buildstream/_artifact.py
index b63cff6e5..9809ac822 100644
--- a/src/buildstream/_artifact.py
+++ b/src/buildstream/_artifact.py
@@ -613,10 +613,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()
#