diff options
author | Jürg Billeter <j@bitron.ch> | 2018-01-22 19:46:38 +0000 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2018-01-23 12:01:37 +0000 |
commit | 4df5d035f62ecee62d679323e4e770625957827c (patch) | |
tree | 4d2c622d1afa2f35c89387faa92a849be6bfd061 | |
parent | af7ffc6d64964b8e6731c4157a8a42fb718734c0 (diff) | |
download | buildstream-4df5d035f62ecee62d679323e4e770625957827c.tar.gz |
element.py: Do not query caches too early or too late
The strict cache key is preferred when pulling or extracting artifacts
in non-strict mode, before falling back to the weak cache key. This
means that the strict cache key must be available before the cache is
queried.
The strict cache key is also sufficient for querying caches using strong
cache keys. Do not defer those cache queries.
Fixes #202
-rw-r--r-- | buildstream/element.py | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/buildstream/element.py b/buildstream/element.py index 95468d2e0..138096caf 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -1398,12 +1398,6 @@ class Element(Plugin): # Weak cache key could not be calculated yet return - # Update __cached in non-strict builds now that the weak cache key is available - if not self._get_strict() and not self.__cached: - self.__cached = self.__artifacts.contains(self) - if not self._get_strict() and not self.__remotely_cached: - self.__remotely_cached = self.__artifacts.remote_contains(self) - if self.__strict_cache_key is None: dependencies = [ e.__strict_cache_key for e in self.dependencies(Scope.BUILD) @@ -1414,6 +1408,16 @@ class Element(Plugin): # Strict cache key could not be calculated yet return + # Query caches now that the weak and strict cache keys are available + if not self.__cached: + self.__cached = self.__artifacts.contains(self) + if not self.__remotely_cached: + self.__remotely_cached = self.__artifacts.remote_contains(self) + if not self.__strong_cached: + self.__strong_cached = self.__artifacts.contains(self, strength=_KeyStrength.STRONG) + if not self.__remotely_strong_cached: + self.__remotely_strong_cached = self.__artifacts.remote_contains(self, strength=_KeyStrength.STRONG) + if self.__cache_key is None: # Calculate strong cache key if self._get_strict(): @@ -1434,17 +1438,6 @@ class Element(Plugin): # Strong cache key could not be calculated yet return - # Update __strong_cached for non-strict builds now that the strong cache key is available - if not self.__strong_cached: - self.__strong_cached = self.__artifacts.contains(self, strength=_KeyStrength.STRONG) - if not self.__remotely_strong_cached: - self.__remotely_strong_cached = self.__artifacts.remote_contains(self, strength=_KeyStrength.STRONG) - - if self._get_strict() and not self.__cached: - self.__cached = self.__strong_cached - if self._get_strict() and not self.__remotely_cached: - self.__remotely_cached = self.__remotely_strong_cached - ############################################################# # Private Local Methods # ############################################################# |