summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-10-15 11:59:58 +0200
committerbst-marge-bot <marge-bot@buildstream.build>2019-11-05 07:42:05 +0000
commit336fef98998d847dcf3df7d520a6bc1b1f43cb14 (patch)
treeb4185fe898fc1e35be01ac9d74e6a1393f7f8cb8
parent601a06ddf8ffa1cc797be0c64ac2e74b35c52d74 (diff)
downloadbuildstream-336fef98998d847dcf3df7d520a6bc1b1f43cb14.tar.gz
cascache.py: Always update mtime in contains_directory()
This is required for LRU cache expiry.
-rw-r--r--src/buildstream/_artifact.py2
-rw-r--r--src/buildstream/_cas/cascache.py18
2 files changed, 8 insertions, 12 deletions
diff --git a/src/buildstream/_artifact.py b/src/buildstream/_artifact.py
index 1e3e39b8f..e5174eaea 100644
--- a/src/buildstream/_artifact.py
+++ b/src/buildstream/_artifact.py
@@ -424,7 +424,7 @@ class Artifact():
# Check whether 'files' subdirectory is available, with or without file contents
if (require_directories and str(artifact.files) and
- not self._cas.contains_directory(artifact.files, with_files=require_files, update_mtime=True)):
+ not self._cas.contains_directory(artifact.files, with_files=require_files)):
self._cached = False
return False
diff --git a/src/buildstream/_cas/cascache.py b/src/buildstream/_cas/cascache.py
index 4ee575d05..b2158597e 100644
--- a/src/buildstream/_cas/cascache.py
+++ b/src/buildstream/_cas/cascache.py
@@ -251,33 +251,29 @@ class CASCache():
# Args:
# digest (Digest): The directory digest to check
# with_files (bool): Whether to check files as well
- # update_mtime (bool): Whether to update the timestamp
#
# Returns: True if the directory is available in the local cache
#
- def contains_directory(self, digest, *, with_files, update_mtime=False):
+ def contains_directory(self, digest, *, with_files):
try:
directory = remote_execution_pb2.Directory()
path = self.objpath(digest)
with open(path, 'rb') as f:
directory.ParseFromString(f.read())
- if update_mtime:
- os.utime(f.fileno())
+ os.utime(f.fileno())
# Optionally check presence of files
if with_files:
for filenode in directory.files:
path = self.objpath(filenode.digest)
- if update_mtime:
- # No need for separate `exists()` call as this will raise
- # FileNotFoundError if the file does not exist.
- os.utime(path)
- elif not os.path.exists(path):
- return False
+
+ # No need for separate `exists()` call as this will raise
+ # FileNotFoundError if the file does not exist.
+ os.utime(path)
# Check subdirectories
for dirnode in directory.directories:
- if not self.contains_directory(dirnode.digest, with_files=with_files, update_mtime=update_mtime):
+ if not self.contains_directory(dirnode.digest, with_files=with_files):
return False
return True