aboutsummaryrefslogtreecommitdiff
path: root/tools/cache.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-12-01 20:05:30 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-12-01 20:05:30 -0800
commit7069a576b23f98762034fcb2025b9ac3ce0a12d4 (patch)
tree847418137252180383a9e76cdb71d4da780f0a0a /tools/cache.py
parentc2077a787657f59623961437a5c604e34a2fb799 (diff)
parent0f5135e436a80b8d13c61da87c943ec1238b42c7 (diff)
Merge pull request #1882 from abergmeier/safe_ensure_dirs
Introduce safe_ensure_dirs as a safe os.makedirs replacement.
Diffstat (limited to 'tools/cache.py')
-rw-r--r--tools/cache.py15
1 files changed, 3 insertions, 12 deletions
diff --git a/tools/cache.py b/tools/cache.py
index ed4fcd24..8883a740 100644
--- a/tools/cache.py
+++ b/tools/cache.py
@@ -1,6 +1,7 @@
import os.path, sys, shutil, hashlib, cPickle, zlib, time
import tempfiles
+import shared
# Permanent cache for dlmalloc and stdlibc++
class Cache:
@@ -13,13 +14,7 @@ class Cache:
self.debug = debug
def ensure(self):
- 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
+ shared.safe_ensure_dirs(self.dirname)
def erase(self):
tempfiles.try_delete(self.dirname)
@@ -53,11 +48,7 @@ class JCache:
def ensure(self):
self.cache.ensure()
- if not os.path.exists(self.dirname):
- try:
- os.makedirs(self.dirname)
- except (IOError, OSError):
- pass
+ shared.safe_ensure_dirs(self.dirname)
def get_shortkey(self, keys):
if type(keys) not in [list, tuple]: