From 65238dfb61408b31cefe692dda206bc8fd346ae8 Mon Sep 17 00:00:00 2001 From: James Ennis Date: Thu, 8 Aug 2019 09:06:33 +0100 Subject: cascache.py: Add new contains_file() method --- src/buildstream/_cas/cascache.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/buildstream/_cas/cascache.py b/src/buildstream/_cas/cascache.py index 192d7992b..ff16480b1 100644 --- a/src/buildstream/_cas/cascache.py +++ b/src/buildstream/_cas/cascache.py @@ -116,6 +116,18 @@ class CASCache(): # This assumes that the repository doesn't have any dangling pointers return os.path.exists(refpath) + # contains_file(): + # + # Check whether a digest corresponds to a file which exists in CAS + # + # Args: + # digest (Digest): The file digest to check + # + # Returns: True if the file is in the cache, False otherwise + # + def contains_file(self, digest): + return os.path.exists(self.objpath(digest)) + # contains_directory(): # # Check whether the specified directory and subdirectories are in the cache, -- cgit v1.2.1