summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2017-07-18 11:18:40 +0200
committerJürg Billeter <j@bitron.ch>2017-07-20 07:24:56 +0200
commitc37662f3088e0fe2c9647fa2a57c3336dac78135 (patch)
tree818964f0c567e5ff732a37af244eeddcadf057fb
parent21f546fa35eaefef2048918afa83b1f222d6839c (diff)
downloadbuildstream-c37662f3088e0fe2c9647fa2a57c3336dac78135.tar.gz
_artifactcache: Add remote_contains()
-rw-r--r--buildstream/_artifactcache/artifactcache.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py
index 81d3adc4a..d65dc4700 100644
--- a/buildstream/_artifactcache/artifactcache.py
+++ b/buildstream/_artifactcache/artifactcache.py
@@ -87,6 +87,31 @@ class ArtifactCache():
ref = buildref(element, key)
return _ostree.exists(self.repo, ref)
+ # remote_contains():
+ #
+ # Check whether the artifact for the specified Element is already available
+ # in the remote artifact cache.
+ #
+ # Args:
+ # element (Element): The Element to check
+ # strength (_KeyStrength): Either STRONG or WEAK key strength, or None
+ #
+ # Returns: True if the artifact is in the cache, False otherwise
+ #
+ def remote_contains(self, element, strength=None):
+ if not self.__remote_refs:
+ return False
+
+ if strength is None:
+ strength = _KeyStrength.STRONG if self.context.strict_build_plan else _KeyStrength.WEAK
+
+ key = element._get_cache_key(strength)
+ if not key:
+ return False
+
+ ref = buildref(element, key)
+ return ref in self.__remote_refs
+
# remove():
#
# Removes the artifact for the specified Element from the local artifact