diff options
author | Darius Makovsky <traveltissues@protonmail.com> | 2019-07-19 17:12:39 +0100 |
---|---|---|
committer | James Ennis <james.ennis@codethink.co.uk> | 2019-08-02 10:04:14 +0100 |
commit | 8d8af22f0ef7c3846c28fb0610f79c1657a2f13a (patch) | |
tree | 12b983d84c6834b6e387b04ceb248953f9abd516 | |
parent | 3d224253b3448517f5bd36e68e9ff6ac205a0ca9 (diff) | |
download | buildstream-traveltissues/setstability.tar.gz |
Add element._set_cache_keys_stability()traveltissues/setstability
This method assigns the value of element.__cache_keys_stability. If the
value was previously `None` then this is `True` if the element is
workspaced otherwise it is `False`. If the value was not `None` and the
element is cached or otherwise not scheduled for assembly then it is
also assigned `False`.
-rw-r--r-- | src/buildstream/element.py | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/buildstream/element.py b/src/buildstream/element.py index df96d04ba..21c38bc1a 100644 --- a/src/buildstream/element.py +++ b/src/buildstream/element.py @@ -1195,8 +1195,8 @@ class Element(Plugin): self.__reset_cache_data() if not self.__assemble_scheduled: self._schedule_assemble() - else: - self.__cache_keys_unstable = False + + self.__update_cache_keys_stability() # Workspaced sources are considered unstable if a build is pending # as the build will modify the contents of the workspace. @@ -1530,10 +1530,7 @@ class Element(Plugin): self.__assemble_scheduled = False self.__assemble_done = True - - # If we've just assembled the Element, we are safe to - # consider the cache keys as stable - self.__cache_keys_unstable = False + self.__update_cache_keys_stability() # Artifact may have a cached success now. if self.__strict_artifact: @@ -1799,10 +1796,7 @@ class Element(Plugin): self.__strict_artifact.reset_cached() self.__artifact.reset_cached() - # If we've just successfully pulled the element, we are safe - # to consider its keys as stable - if self.__cache_keys_unstable and self._cached_success(): - self.__cache_keys_unstable = False + self.__update_cache_keys_stability() self._update_state() self._update_ready_for_runtime_and_cached() @@ -3148,6 +3142,22 @@ class Element(Plugin): if context.get_strict(): self.__artifact = self.__strict_artifact + # __update_cache_keys_stability() + # + # Update the __cache_keys_unstable attribute. + # + # Workspaces are considered to be unstable on a new element instance. + # Otherwise if the element is cached or the build is done, then keys + # are considered to be stable. In other cases there is no change to + # the attribute. + # + def __update_cache_keys_stability(self): + if self.__cache_keys_unstable: + if self._cached_success(): + self.__cache_keys_unstable = False + elif not self.__assemble_scheduled and self.__assemble_done: + self.__cache_keys_unstable = False + # __update_cache_key_non_strict() # # Calculates the strong cache key if it hasn't already been set. |