summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Maw <jonathan.maw@codethink.co.uk>2019-05-08 17:25:03 +0100
committerJonathan Maw <jonathan.maw@codethink.co.uk>2019-05-17 13:57:25 +0100
commitc066f6be433873c44f2f0825f357c58a02223753 (patch)
treeea48eecf19c87781e16ba1762b3d8e32285916d8
parent8e8a82187d294b170fade96b61f777e7a3773833 (diff)
downloadbuildstream-shared/split_out_update_state_3.tar.gz
element.py: Don't calculate strong key if not requiredshared/split_out_update_state_3
-rw-r--r--buildstream/_cachekeycontroller/nonstrictcachekeycontroller.py6
-rw-r--r--buildstream/element.py6
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: