summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2018-02-27 05:39:58 +0100
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2018-02-27 11:43:17 +0000
commitf439e26a4f75a8529a528612ee99e224411f7ffc (patch)
tree988ab585edfa5b0805cbe9f94a0b162e1e2a33dc
parente99e22c262941fa9cc38c5546f2b54bb5d8e191f (diff)
downloadbuildstream-f439e26a4f75a8529a528612ee99e224411f7ffc.tar.gz
_artifactcache: Add key parameter to push_needed() method
Contain cache key logic in Element class.
-rw-r--r--buildstream/_artifactcache/artifactcache.py3
-rw-r--r--buildstream/_artifactcache/ostreecache.py7
-rw-r--r--buildstream/element.py7
3 files changed, 10 insertions, 7 deletions
diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py
index 0bbb05255..da6bed5d6 100644
--- a/buildstream/_artifactcache/artifactcache.py
+++ b/buildstream/_artifactcache/artifactcache.py
@@ -238,10 +238,11 @@ class ArtifactCache():
#
# Args:
# element (Element): The Element to check
+ # key (str): The cache key to use
#
# Returns: False if all the push remotes have the artifact, True otherwise
#
- def push_needed(self, element):
+ def push_needed(self, element, key):
return False
# push():
diff --git a/buildstream/_artifactcache/ostreecache.py b/buildstream/_artifactcache/ostreecache.py
index 6a7ee2a46..4676e43d6 100644
--- a/buildstream/_artifactcache/ostreecache.py
+++ b/buildstream/_artifactcache/ostreecache.py
@@ -189,14 +189,11 @@ class OSTreeCache(ArtifactCache):
#
# Args:
# element (Element): The Element to check
+ # key (str): The cache key to use
#
# Returns: False if all the push remotes have the artifact, True otherwise
#
- def push_needed(self, element):
- key = element._get_cache_key(strength=_KeyStrength.STRONG)
-
- if not key:
- return False
+ def push_needed(self, element, key):
remotes_with_artifact = self.remotes_containing_key(element, key)
diff --git a/buildstream/element.py b/buildstream/element.py
index 86bdb248b..433521329 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -1160,8 +1160,13 @@ class Element(Plugin):
if self._tainted():
return True
+ # Use the strong cache key to check whether a remote already has the artifact.
+ # In non-strict mode we want to push updated artifacts even if the
+ # remote already has an artifact with the same weak cache key.
+ key = self._get_cache_key(strength=_KeyStrength.STRONG)
+
# Skip if every push remote contains this element already.
- if self.__artifacts.push_needed(self):
+ if self.__artifacts.push_needed(self, key):
return False
else:
return True