From 4fdd4d5fa4df797a84272d9ffa4bedcc4baf8af0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Billeter?= Date: Wed, 19 Jul 2017 08:03:33 +0200 Subject: _artifactcache: Add remote_contains_key() --- buildstream/_artifactcache/artifactcache.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py index 6be654210..e8ec28abc 100644 --- a/buildstream/_artifactcache/artifactcache.py +++ b/buildstream/_artifactcache/artifactcache.py @@ -87,21 +87,36 @@ class ArtifactCache(): ref = buildref(element, key) return _ostree.exists(self.repo, ref) - # remote_contains(): + # remote_contains_key(): # # 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 + # key (str): The key to use # # Returns: True if the artifact is in the cache, False otherwise # - def remote_contains(self, element, strength=None): + def remote_contains_key(self, element, key): if not self.__remote_refs: return False + ref = buildref(element, key) + return ref in self.__remote_refs + + # 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 strength is None: strength = _KeyStrength.STRONG if self.context.strict_build_plan else _KeyStrength.WEAK @@ -109,8 +124,7 @@ class ArtifactCache(): if not key: return False - ref = buildref(element, key) - return ref in self.__remote_refs + return self.remote_contains_key(element, key) # remove(): # -- cgit v1.2.1