summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-08-29 10:10:51 +0200
committerJürg Billeter <j@bitron.ch>2019-08-29 16:49:15 +0200
commite97a3270031bb03fca9ff4f8a7bdb29af684c362 (patch)
tree4d3db9954ca360aea5f73330b1d2ac088f927ca9
parentf4d4a7c6f73a4a705c91d0628bf62916eace0541 (diff)
downloadbuildstream-e97a3270031bb03fca9ff4f8a7bdb29af684c362.tar.gz
_context.py: Fix quota error when cas directory does not exist yet
If the quota is configured as percentage of total disk space, we need to make sure that _get_volume_size() does not fail if the cas directory does not exist yet.
-rw-r--r--src/buildstream/_context.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py
index b70f80d73..0d250eb56 100644
--- a/src/buildstream/_context.py
+++ b/src/buildstream/_context.py
@@ -270,14 +270,18 @@ class Context():
# Load quota configuration
# We need to find the first existing directory in the path of our
- # cachedir - the cachedir may not have been created yet.
+ # casdir - the casdir may not have been created yet.
cache = defaults.get_mapping('cache')
cache.validate_keys(['quota', 'pull-buildtrees', 'cache-buildtrees'])
+ cas_volume = self.casdir
+ while not os.path.exists(cas_volume):
+ cas_volume = os.path.dirname(cas_volume)
+
self.config_cache_quota_string = cache.get_str('quota')
try:
self.config_cache_quota = utils._parse_size(self.config_cache_quota_string,
- self.casdir)
+ cas_volume)
except utils.UtilError as e:
raise LoadError("{}\nPlease specify the value in bytes or as a % of full disk space.\n"
"\nValid values are, for example: 800M 10G 1T 50%\n"