aboutsummaryrefslogtreecommitdiff
path: root/tools/cache.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-11-27 14:13:55 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-11-27 14:13:55 -0800
commitacb425c435975eb24b822aec8ff1074ce55b6800 (patch)
treeb2fa98259504d4d65ec2170adaefad86152f618a /tools/cache.py
parentbcdc625839fdb1ce9ea610f01eee13ca4b3454b8 (diff)
parent255cb2c177b81853f508f380b6a4a71d0f39b5e6 (diff)
Merge pull request #1862 from abergmeier/prevent_false_negative_in_cache
Prevent Cache.ensure from throwing an error, while the directory already...
Diffstat (limited to 'tools/cache.py')
-rw-r--r--tools/cache.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/cache.py b/tools/cache.py
index c316a1fd..ed4fcd24 100644
--- a/tools/cache.py
+++ b/tools/cache.py
@@ -13,8 +13,13 @@ class Cache:
self.debug = debug
def ensure(self):
- if not os.path.exists(self.dirname):
+ try:
+ # Use makedirs here, so creating the path is as atomic as possible
os.makedirs(self.dirname)
+ except os.error, e:
+ # Ignore error for already existing dirname
+ if not os.path.exists(self.dirname):
+ raise e
def erase(self):
tempfiles.try_delete(self.dirname)