summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Maw <jonathan.maw@codethink.co.uk>2019-05-22 12:30:54 +0100
committerJonathan Maw <jonathan.maw@codethink.co.uk>2019-05-22 16:31:13 +0000
commit423245ae8502e6ae886576a2c6797acc86f60bc7 (patch)
treec457b2b00aae7d573a58665b63ee8375f4357c30
parent57212ca1881918696af55527fc833e9f8665425b (diff)
downloadbuildstream-jonathan/reset_cached_when_needed.tar.gz
element.py: Only reset Artifact's cachedness when it might changejonathan/reset_cached_when_needed
i.e. after calculating the original cached state (as soon as weak/strict cache keys are available), cachedness needs to be reset if the artifact may have appeared on the filesystem. We expect that to happen after _pull_done() or _assemble_done()
-rw-r--r--src/buildstream/_artifact.py9
-rw-r--r--src/buildstream/element.py17
2 files changed, 12 insertions, 14 deletions
diff --git a/src/buildstream/_artifact.py b/src/buildstream/_artifact.py
index c353a5151..b3ef005f0 100644
--- a/src/buildstream/_artifact.py
+++ b/src/buildstream/_artifact.py
@@ -398,15 +398,8 @@ class Artifact():
# Allow the Artifact to query the filesystem to determine whether it
# is cached or not.
#
- # NOTE: Due to the fact that a normal buildstream run does not make an
- # artifact *not* cached (`bst artifact delete` can do so, but doesn't
- # query the Artifact afterwards), it does not update_cached if the
- # artifact is already cached. If a cached artifact ever has its key
- # changed, this will need to be revisited.
- #
def reset_cached(self):
- if self._cached is False:
- self._cached = None
+ self._cached = None
# _get_proto()
#
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index 70158f778..08326c6f3 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -1566,6 +1566,12 @@ class Element(Plugin):
self.__assemble_scheduled = False
self.__assemble_done = True
+ # Artifact may have a cached success now.
+ if self.__strict_artifact:
+ self.__strict_artifact.reset_cached()
+ if self.__artifact:
+ self.__artifact.reset_cached()
+
self.__update_state_recursively()
if self._get_workspace() and self._cached_success():
@@ -1817,6 +1823,11 @@ class Element(Plugin):
def _pull_done(self):
self.__pull_done = True
+ # Artifact may become cached after pulling, so let it query the
+ # filesystem again to check
+ self.__strict_artifact.reset_cached()
+ self.__artifact.reset_cached()
+
self.__update_state_recursively()
# _pull():
@@ -2967,12 +2978,6 @@ class Element(Plugin):
self.__cache_key = self.__strict_cache_key
self.__artifact = self.__strict_artifact
- # Allow caches to be queried, since they may now be cached
- # The next invocation of Artifact.cached() will access the filesystem.
- # Note that this will safely do nothing if the artifacts are already cached.
- self.__strict_artifact.reset_cached()
- self.__artifact.reset_cached()
-
# __update_cache_key_non_strict()
#
# Calculates the strong cache key if it hasn't already been set.