Show More
@@ -307,7 +307,7 b' class vfs(abstractvfs):' | |||||
307 | if basename: |
|
307 | if basename: | |
308 | if atomictemp: |
|
308 | if atomictemp: | |
309 | if not os.path.isdir(dirname): |
|
309 | if not os.path.isdir(dirname): | |
310 |
util. |
|
310 | util.ensuredirs(dirname, self.createmode) | |
311 | return util.atomictempfile(f, mode, self.createmode) |
|
311 | return util.atomictempfile(f, mode, self.createmode) | |
312 | try: |
|
312 | try: | |
313 | if 'w' in mode: |
|
313 | if 'w' in mode: | |
@@ -326,7 +326,7 b' class vfs(abstractvfs):' | |||||
326 | raise |
|
326 | raise | |
327 | nlink = 0 |
|
327 | nlink = 0 | |
328 | if not os.path.isdir(dirname): |
|
328 | if not os.path.isdir(dirname): | |
329 |
util. |
|
329 | util.ensuredirs(dirname, self.createmode) | |
330 | if nlink > 0: |
|
330 | if nlink > 0: | |
331 | if self._trustnlink is None: |
|
331 | if self._trustnlink is None: | |
332 | self._trustnlink = nlink > 1 or util.checknlink(f) |
|
332 | self._trustnlink = nlink > 1 or util.checknlink(f) | |
@@ -347,7 +347,7 b' class vfs(abstractvfs):' | |||||
347 |
|
347 | |||
348 | dirname = os.path.dirname(linkname) |
|
348 | dirname = os.path.dirname(linkname) | |
349 | if not os.path.exists(dirname): |
|
349 | if not os.path.exists(dirname): | |
350 |
util. |
|
350 | util.ensuredirs(dirname, self.createmode) | |
351 |
|
351 | |||
352 | if self._cansymlink: |
|
352 | if self._cansymlink: | |
353 | try: |
|
353 | try: |
@@ -880,6 +880,16 b' def makedirs(name, mode=None):' | |||||
880 | if mode is not None: |
|
880 | if mode is not None: | |
881 | os.chmod(name, mode) |
|
881 | os.chmod(name, mode) | |
882 |
|
882 | |||
|
883 | def ensuredirs(name, mode=None): | |||
|
884 | """race-safe recursive directory creation""" | |||
|
885 | try: | |||
|
886 | makedirs(name, mode) | |||
|
887 | except OSError, err: | |||
|
888 | if err.errno == errno.EEXIST and os.path.isdir(name): | |||
|
889 | # someone else seems to have won a directory creation race | |||
|
890 | return | |||
|
891 | raise | |||
|
892 | ||||
883 | def readfile(path): |
|
893 | def readfile(path): | |
884 | fp = open(path, 'rb') |
|
894 | fp = open(path, 'rb') | |
885 | try: |
|
895 | try: |
General Comments 0
You need to be logged in to leave comments.
Login now