aboutsummaryrefslogtreecommitdiff
path: root/tools/cache.py
diff options
context:
space:
mode:
authorAndreas Bergmeier <abergmeier@gmx.net>2013-11-26 18:29:01 +0100
committerAndreas Bergmeier <abergmeier@gmx.net>2013-11-26 18:29:01 +0100
commit255cb2c177b81853f508f380b6a4a71d0f39b5e6 (patch)
treef131e7ab8f2d9a95aa6afb5ec32ae3f217fd0a5d /tools/cache.py
parent37d83ff57f5ddcf584e93695cadba623614b1fdc (diff)
Prevent Cache.ensure from throwing an error, while the directory already exists.
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)