diff options
author | bst-marge-bot <marge-bot@buildstream.build> | 2019-08-06 10:33:04 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-08-06 10:33:04 +0000 |
commit | ae518d4407f48e738741cd998eddf527b73e94f0 (patch) | |
tree | 5d4b04cd034eed6cbdbd885ac2a83726219bdd2c | |
parent | 7adc250f68f6f9e0cc20f41bf8bab7931f48311f (diff) | |
parent | 00d1126ecb1e41b80a559ce63fe75c62fe7aa453 (diff) | |
download | buildstream-ae518d4407f48e738741cd998eddf527b73e94f0.tar.gz |
Merge branch 'traveltissues/setstability' into 'master'
Add Element.__update_cache_keys_stability method
Closes #1087
See merge request BuildStream/buildstream!1492
-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. |