diff options
author | willmcgugan <willmcgugan@67cdc799-7952-0410-af00-57a81ceafa0f> | 2008-09-16 11:47:46 +0000 |
---|---|---|
committer | willmcgugan <willmcgugan@67cdc799-7952-0410-af00-57a81ceafa0f> | 2008-09-16 11:47:46 +0000 |
commit | 51f6d0062cde94a19603137a3b7c07d87b356943 (patch) | |
tree | c373d37470612a2f8bb6bd33d7bacc86ad8cbfbc /fs/zipfs.py | |
parent | 1fd5453afc40a8a9a4eb2a3591b684681c9500b9 (diff) | |
download | pyfilesystem-git-51f6d0062cde94a19603137a3b7c07d87b356943.tar.gz |
Added a thread lock to makedir
Diffstat (limited to 'fs/zipfs.py')
-rw-r--r-- | fs/zipfs.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/fs/zipfs.py b/fs/zipfs.py index 98f9e6b..171f810 100644 --- a/fs/zipfs.py +++ b/fs/zipfs.py @@ -172,12 +172,16 @@ class ZipFS(FS): return self._path_fs.exists(path) def makedir(self, dirname, mode=0777, recursive=False, allow_recreate=False): - dirname = normpath(dirname) - if self.zip_mode not in "wa": - raise OperationFailedError("MAKEDIR_FAILED", dirname, "Zip file must be opened for writing ('w') or appending ('a')") - if not dirname.endswith('/'): - dirname += '/' - self._add_resource(dirname) + self._lock.acquire() + try: + dirname = normpath(dirname) + if self.zip_mode not in "wa": + raise OperationFailedError("MAKEDIR_FAILED", dirname, "Zip file must be opened for writing ('w') or appending ('a')") + if not dirname.endswith('/'): + dirname += '/' + self._add_resource(dirname) + finally: + self._lock.release() def listdir(self, path="/", wildcard=None, full=False, absolute=False, hidden=False, dirs_only=False, files_only=False): |