diff options
author | Jürg Billeter <j@bitron.ch> | 2017-07-18 11:18:40 +0200 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2017-07-20 07:24:56 +0200 |
commit | c37662f3088e0fe2c9647fa2a57c3336dac78135 (patch) | |
tree | 818964f0c567e5ff732a37af244eeddcadf057fb | |
parent | 21f546fa35eaefef2048918afa83b1f222d6839c (diff) | |
download | buildstream-c37662f3088e0fe2c9647fa2a57c3336dac78135.tar.gz |
_artifactcache: Add remote_contains()
-rw-r--r-- | buildstream/_artifactcache/artifactcache.py | 25 |
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 |