diff options
author | willmcgugan <willmcgugan@67cdc799-7952-0410-af00-57a81ceafa0f> | 2012-01-11 23:20:40 +0000 |
---|---|---|
committer | willmcgugan <willmcgugan@67cdc799-7952-0410-af00-57a81ceafa0f> | 2012-01-11 23:20:40 +0000 |
commit | 60da3d535a5d591b7003e93e66364bd6ea161461 (patch) | |
tree | 004a11f32f97d350eeade38c97cb933c4c08d282 /fs/wrapfs | |
parent | db293aaba268dff6cd9085be9adfc9f0c90ef8aa (diff) | |
download | pyfilesystem-git-60da3d535a5d591b7003e93e66364bd6ea161461.tar.gz |
Fixed copydir/movedir, added DeleteRootError
Diffstat (limited to 'fs/wrapfs')
-rw-r--r-- | fs/wrapfs/__init__.py | 7 | ||||
-rw-r--r-- | fs/wrapfs/lazyfs.py | 2 | ||||
-rw-r--r-- | fs/wrapfs/subfs.py | 53 |
3 files changed, 37 insertions, 25 deletions
diff --git a/fs/wrapfs/__init__.py b/fs/wrapfs/__init__.py index 556f522..7b9d1af 100644 --- a/fs/wrapfs/__init__.py +++ b/fs/wrapfs/__init__.py @@ -18,6 +18,7 @@ standard unix shell functionality of hiding dot-files in directory listings. import re import sys import fnmatch +import threading from fs.base import FS, threading, synchronize, NoDefaultMeta from fs.errors import * @@ -65,11 +66,11 @@ class WrapFS(FS): """ def __init__(self, fs): - super(WrapFS,self).__init__() + super(WrapFS, self).__init__() try: self._lock = fs._lock - except (AttributeError,FSError): - self._lock = None + except (AttributeError,FSError): + self._lock = self._lock = threading.RLock() self.wrapped_fs = fs def _file_wrap(self, f, mode): diff --git a/fs/wrapfs/lazyfs.py b/fs/wrapfs/lazyfs.py index 02fa1f7..0c1d2e9 100644 --- a/fs/wrapfs/lazyfs.py +++ b/fs/wrapfs/lazyfs.py @@ -29,7 +29,7 @@ class LazyFS(WrapFS): """ def __init__(self, fs): - super(LazyFS,self).__init__(fs) + super(LazyFS, self).__init__(fs) self._lazy_creation_lock = Lock() def __unicode__(self): diff --git a/fs/wrapfs/subfs.py b/fs/wrapfs/subfs.py index 79b1e58..1d221a4 100644 --- a/fs/wrapfs/subfs.py +++ b/fs/wrapfs/subfs.py @@ -60,27 +60,38 @@ class SubFS(WrapFS): def removedir(self, path, recursive=False, force=False): # Careful not to recurse outside the subdir path = normpath(path) - if path in ("","/"): - if not force: - for path2 in self.listdir(path): - raise DirectoryNotEmptyError(path) - else: - for path2 in self.listdir(path,absolute=True,files_only=True): - try: - self.remove(path2) - except ResourceNotFoundError: - pass - for path2 in self.listdir(path,absolute=True,dirs_only=True): - try: - self.removedir(path2,force=True) - except ResourceNotFoundError: - pass - else: - super(SubFS,self).removedir(path,force=force) - if recursive: - try: + if path in ('', '/'): + raise DeleteRootError(path) + super(SubFS,self).removedir(path,force=force) + if recursive: + try: + if dirname(path) not in ('', '/'): self.removedir(dirname(path),recursive=True) - except DirectoryNotEmptyError: - pass + except DirectoryNotEmptyError: + pass + +# if path in ("","/"): +# if not force: +# for path2 in self.listdir(path): +# raise DirectoryNotEmptyError(path) +# else: +# for path2 in self.listdir(path,absolute=True,files_only=True): +# try: +# self.remove(path2) +# except ResourceNotFoundError: +# pass +# for path2 in self.listdir(path,absolute=True,dirs_only=True): +# try: +# self.removedir(path2,force=True) +# except ResourceNotFoundError: +# pass +# else: +# super(SubFS,self).removedir(path,force=force) +# if recursive: +# try: +# if dirname(path): +# self.removedir(dirname(path),recursive=True) +# except DirectoryNotEmptyError: +# pass |