summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2018-09-27 09:58:26 +0100
committerJürg Billeter <j@bitron.ch>2018-09-27 10:18:03 +0100
commit10ed9158f0ce91bc18ba4e78f6a44a8595af731e (patch)
tree3b7980661fbe035d8b32c9bb53e257818feac032
parentf08e5eae17d4b11f84c6a72640145dcb84fa02eb (diff)
downloadbuildstream-10ed9158f0ce91bc18ba4e78f6a44a8595af731e.tar.gz
_artifactcache: Add preflight() method
-rw-r--r--buildstream/_artifactcache/artifactcache.py7
-rw-r--r--buildstream/_artifactcache/cascache.py6
2 files changed, 13 insertions, 0 deletions
diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py
index f4157c7ef..6a9b57f2c 100644
--- a/buildstream/_artifactcache/artifactcache.py
+++ b/buildstream/_artifactcache/artifactcache.py
@@ -383,6 +383,13 @@ class ArtifactCache():
# Abstract methods for subclasses to implement #
################################################
+ # preflight():
+ #
+ # Preflight check.
+ #
+ def preflight(self):
+ pass
+
# update_atime()
#
# Update the atime of an artifact.
diff --git a/buildstream/_artifactcache/cascache.py b/buildstream/_artifactcache/cascache.py
index 137bcbc5a..936cb780b 100644
--- a/buildstream/_artifactcache/cascache.py
+++ b/buildstream/_artifactcache/cascache.py
@@ -80,6 +80,12 @@ class CASCache(ArtifactCache):
# Implementation of abstract methods #
################################################
+ def preflight(self):
+ if (not os.path.isdir(os.path.join(self.casdir, 'refs', 'heads')) or
+ not os.path.isdir(os.path.join(self.casdir, 'objects'))):
+ raise ArtifactError("CAS repository check failed for '{}'"
+ .format(self.casdir))
+
def contains(self, element, key):
refpath = self._refpath(self.get_artifact_fullname(element, key))