diff options
author | James Ennis <james.ennis@codethink.com> | 2019-01-11 15:49:48 +0000 |
---|---|---|
committer | James Ennis <james.ennis@codethink.com> | 2019-01-17 12:36:02 +0000 |
commit | 38a09bf32ff4f80e8111ec88dfbec69b1cb1bc69 (patch) | |
tree | 6a66e0703001d4480a449cc65cf41c825735440c | |
parent | cc2f2957e2c50ae8b07bf56ad882b238107d5c9d (diff) | |
download | buildstream-38a09bf32ff4f80e8111ec88dfbec69b1cb1bc69.tar.gz |
artifactcache.py: API Cleanup - Add contains_ref() method
This ensures that we can determine whether an artifact is locally cached
(as well as an element) using the ArtifactCache API.
-rw-r--r-- | buildstream/_artifactcache.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/buildstream/_artifactcache.py b/buildstream/_artifactcache.py index 7bd5a531d..24e6a3a0d 100644 --- a/buildstream/_artifactcache.py +++ b/buildstream/_artifactcache.py @@ -407,18 +407,30 @@ class ArtifactCache(): # contains(): # - # Check whether the artifact for the specified Element is already available - # in the local artifact cache. + # Check whether the (project state) artifact of the specified Element is + # already available in the local artifact cache. # # Args: # element (Element): The Element to check # key (str): The cache key to use # - # Returns: True if the artifact is in the cache, False otherwise + # Returns: True if the Element's (project state) artifact is in the cache, + # False otherwise # def contains(self, element, key): ref = self.get_artifact_fullname(element, key) + return self.contains_ref(ref) + # contains_ref(): + # + # Check whether an artifact is already available in the local artifact cache. + # + # Args: + # ref (str): The ref to check + # + # Returns: True if the artifact is in the cache, False otherwise + # + def contains_ref(self, ref): return self.cas.contains(ref) # contains_subdir_artifact(): |