diff options
author | Jonathan Maw <jonathan.maw@codethink.co.uk> | 2019-05-23 09:00:07 +0000 |
---|---|---|
committer | Jonathan Maw <jonathan.maw@codethink.co.uk> | 2019-05-23 09:00:07 +0000 |
commit | 156affd4a33562bd383b5fc598fb95b9f99da0ea (patch) | |
tree | c457b2b00aae7d573a58665b63ee8375f4357c30 | |
parent | 57212ca1881918696af55527fc833e9f8665425b (diff) | |
parent | 423245ae8502e6ae886576a2c6797acc86f60bc7 (diff) | |
download | buildstream-156affd4a33562bd383b5fc598fb95b9f99da0ea.tar.gz |
Merge branch 'jonathan/reset_cached_when_needed' into 'master'
element.py: Only reset Artifact's cachedness when it might change
Closes #1028
See merge request BuildStream/buildstream!1352
-rw-r--r-- | src/buildstream/_artifact.py | 9 | ||||
-rw-r--r-- | src/buildstream/element.py | 17 |
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. |