diff options
author | Jürg Billeter <j@bitron.ch> | 2019-08-29 10:10:51 +0200 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2019-08-30 08:16:12 +0000 |
commit | 2ae24387e6103ed4b78647fe005ca5c4c1576fb8 (patch) | |
tree | e7c97987bb7eab5b8d5baf395defc38dea18fc0c | |
parent | f2c3f8eb0db188caac6991632c4453c39b42e84c (diff) | |
download | buildstream-2ae24387e6103ed4b78647fe005ca5c4c1576fb8.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.py | 8 |
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" |