summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/CacheDir.py
diff options
context:
space:
mode:
authorThomas Tanner <trtanner@btinternet.com>2016-03-19 13:09:56 (GMT)
committerThomas Tanner <trtanner@btinternet.com>2016-03-19 13:09:56 (GMT)
commit2bc0caa0e5df6d5602c5640cb54abbacbc74f15c (patch)
treeda4d4b1e2319412edc1a5c1f5be89d77e36a05ad /src/engine/SCons/CacheDir.py
parentb0e44d9dc69b224e75c2ce755ec1a0b7f5585e49 (diff)
downloadSCons-2bc0caa0e5df6d5602c5640cb54abbacbc74f15c.zip
SCons-2bc0caa0e5df6d5602c5640cb54abbacbc74f15c.tar.gz
SCons-2bc0caa0e5df6d5602c5640cb54abbacbc74f15c.tar.bz2
Add some error recovery, cleanup scons-configure-cache
Diffstat (limited to 'src/engine/SCons/CacheDir.py')
-rw-r--r--src/engine/SCons/CacheDir.py28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/engine/SCons/CacheDir.py b/src/engine/SCons/CacheDir.py
index a941986..aaf3c12 100644
--- a/src/engine/SCons/CacheDir.py
+++ b/src/engine/SCons/CacheDir.py
@@ -169,19 +169,35 @@ class CacheDir(object):
global warned
if self.path not in warned:
msg = "Please upgrade your cache by running " +\
- " scons-upgrade-cache.py " + self.path
+ " scons-configure-cache.py " + self.path
SCons.Warnings.warn(SCons.Warnings.CacheVersionWarning, msg)
warned[self.path] = True
else:
if not os.path.isdir(path):
- os.makedirs(path)
+ try:
+ os.makedirs(path)
+ except OSError:
+ # If someone else is trying to create the directory at
+ # the same time as me, bad things will happen
+ msg = "Failed to create cache directory " + path
+ raise SCons.Errors.EnvironmentError(msg)
+
self.config['prefix_len'] = 2
if not os.path.exists(config_file):
- with open(config_file, 'w') as config:
- self.config = json.dump(self.config, config)
+ try:
+ with open(config_file, 'w') as config:
+ self.config = json.dump(self.config, config)
+ except:
+ msg = "Failed to write cache configuration for " + path
+ raise SCons.Errors.EnvironmentError(msg)
else:
- with open(config_file) as config:
- self.config = json.load(config)
+ try:
+ with open(config_file) as config:
+ self.config = json.load(config)
+ except ValueError:
+ msg = "Failed to read cache configuration for " + path
+ raise SCons.Errors.EnvironmentError(msg)
+
def CacheDebug(self, fmt, target, cachefile):
if cache_debug != self.current_cache_debug: