summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2018-02-27 05:39:58 +0100
committerJürg Billeter <j@bitron.ch>2018-02-27 10:59:20 +0100
commit31efda91f92560c744a9083ecd641ff693e58eb5 (patch)
tree852ddd9b9c6ad0f8db3c6e6d81f9b733d0e594a1
parentbe343b81f5e583ed7d33f128338a1916472c9a24 (diff)
downloadbuildstream-31efda91f92560c744a9083ecd641ff693e58eb5.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