diff options
| -rw-r--r-- | buildstream/_cachekeycontroller/nonstrictcachekeycontroller.py | 6 | ||||
| -rw-r--r-- | buildstream/element.py | 6 |
2 files changed, 5 insertions, 7 deletions
diff --git a/buildstream/_cachekeycontroller/nonstrictcachekeycontroller.py b/buildstream/_cachekeycontroller/nonstrictcachekeycontroller.py index 12518a2ec..b47d08848 100644 --- a/buildstream/_cachekeycontroller/nonstrictcachekeycontroller.py +++ b/buildstream/_cachekeycontroller/nonstrictcachekeycontroller.py @@ -46,11 +46,7 @@ class NonStrictCacheKeyController(CacheKeyController): # Load the strong cache key from the artifact self._strong_key = element._get_strong_key_from_artifact() - # XXX: This is a significant change from how strong cache keys were originally - # calculated. It seems to be correct, but I am not certain it's the best way. - # If bugs occur, try replacing the conditional with - # `element._Element__assemble_scheduled or element._Element__assemble_done`. - elif element._is_required(): + else: # Artifact will or has been built, not downloaded dependencies = [ e._get_cache_key() for e in element.dependencies(Scope.BUILD) diff --git a/buildstream/element.py b/buildstream/element.py index b45d99778..c790e77d2 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -2986,8 +2986,10 @@ class Element(Plugin): if not self.__strict_artifact: return - # The final cache key can be None here only in non-strict mode - if not self.__cache_key_ctrl.get_key(_KeyStrength.STRONG): + # The final cache key can be None here only in non-strict mode. + # If it's not required, don't calculate it since it's expensve to try + # to pull it first. + if not self.__cache_key_ctrl.get_key(_KeyStrength.STRONG) and self._is_required(): strong_cache_key = self.__cache_key_ctrl.calculate_strong_key(self) if strong_cache_key is None: |
