Commit 39ef2b67 by willmcgugan

Changed DeleteRootError to RemoveRootError for consistency

parent 60da3d53
...@@ -18,7 +18,7 @@ __all__ = ['FSError', ...@@ -18,7 +18,7 @@ __all__ = ['FSError',
'PermissionDeniedError', 'PermissionDeniedError',
'FSClosedError', 'FSClosedError',
'OperationTimeoutError', 'OperationTimeoutError',
'DeleteRootError', 'RemoveRootError',
'ResourceError', 'ResourceError',
'NoSysPathError', 'NoSysPathError',
'NoMetaError', 'NoMetaError',
...@@ -120,8 +120,8 @@ class OperationTimeoutError(OperationFailedError): ...@@ -120,8 +120,8 @@ class OperationTimeoutError(OperationFailedError):
default_message = "Unable to %(opname)s: operation timed out" default_message = "Unable to %(opname)s: operation timed out"
class DeleteRootError(OperationFailedError): class RemoveRootError(OperationFailedError):
default_message = "Can't delete root dir" default_message = "Can't remove root dir"
class ResourceError(FSError): class ResourceError(FSError):
......
...@@ -1300,7 +1300,7 @@ class FTPFS(FS): ...@@ -1300,7 +1300,7 @@ class FTPFS(FS):
if self.isfile(path): if self.isfile(path):
raise ResourceInvalidError(path) raise ResourceInvalidError(path)
if normpath(path) in ('', '/'): if normpath(path) in ('', '/'):
raise DeleteRootError(path) raise RemoveRootError(path)
if not force: if not force:
for _checkpath in self.listdir(path): for _checkpath in self.listdir(path):
......
...@@ -452,7 +452,7 @@ class MemoryFS(FS): ...@@ -452,7 +452,7 @@ class MemoryFS(FS):
def removedir(self, path, recursive=False, force=False): def removedir(self, path, recursive=False, force=False):
path = normpath(path) path = normpath(path)
if path in ('', '/'): if path in ('', '/'):
raise DeleteRootError(path) raise RemoveRootError(path)
dir_entry = self._get_dir_entry(path) dir_entry = self._get_dir_entry(path)
if dir_entry is None: if dir_entry is None:
...@@ -469,13 +469,13 @@ class MemoryFS(FS): ...@@ -469,13 +469,13 @@ class MemoryFS(FS):
rpathname, dirname = pathsplit(rpathname) rpathname, dirname = pathsplit(rpathname)
parent_dir = self._get_dir_entry(rpathname) parent_dir = self._get_dir_entry(rpathname)
if not dirname: if not dirname:
raise DeleteRootError(path) raise RemoveRootError(path)
del parent_dir.contents[dirname] del parent_dir.contents[dirname]
else: else:
pathname, dirname = pathsplit(path) pathname, dirname = pathsplit(path)
parent_dir = self._get_dir_entry(pathname) parent_dir = self._get_dir_entry(pathname)
if not dirname: if not dirname:
raise DeleteRootError(path) raise RemoveRootError(path)
del parent_dir.contents[dirname] del parent_dir.contents[dirname]
@synchronize @synchronize
......
...@@ -332,7 +332,7 @@ class MountFS(FS): ...@@ -332,7 +332,7 @@ class MountFS(FS):
def removedir(self, path, recursive=False, force=False): def removedir(self, path, recursive=False, force=False):
path = normpath(path) path = normpath(path)
if path in ('', '/'): if path in ('', '/'):
raise DeleteRootError(path) raise RemoveRootError(path)
fs, _mount_path, delegate_path = self._delegate(path) fs, _mount_path, delegate_path = self._delegate(path)
if fs is self or fs is None: if fs is self or fs is None:
raise ResourceInvalidError(path, msg="Can not removedir for an un-mounted path") raise ResourceInvalidError(path, msg="Can not removedir for an un-mounted path")
......
...@@ -294,7 +294,7 @@ class MultiFS(FS): ...@@ -294,7 +294,7 @@ class MultiFS(FS):
if self.writefs is None: if self.writefs is None:
raise OperationFailedError('removedir', path=path, msg="No writeable FS set") raise OperationFailedError('removedir', path=path, msg="No writeable FS set")
if normpath(path) in ('', '/'): if normpath(path) in ('', '/'):
raise DeleteRootError(path) raise RemoveRootError(path)
self.writefs.removedir(path, recursive=recursive, force=force) self.writefs.removedir(path, recursive=recursive, force=force)
@synchronize @synchronize
......
...@@ -287,7 +287,7 @@ class OSFS(OSFSXAttrMixin, OSFSWatchMixin, FS): ...@@ -287,7 +287,7 @@ class OSFS(OSFSXAttrMixin, OSFSWatchMixin, FS):
pass pass
# Don't remove the root directory of this FS # Don't remove the root directory of this FS
if path in ('', '/'): if path in ('', '/'):
raise DeleteRootError(path) raise RemoveRootError(path)
os.rmdir(sys_path) os.rmdir(sys_path)
# Using os.removedirs() for this can result in dirs being # Using os.removedirs() for this can result in dirs being
# removed outside the root of this FS, so we recurse manually. # removed outside the root of this FS, so we recurse manually.
......
...@@ -240,17 +240,17 @@ class WatchedDirectory(object): ...@@ -240,17 +240,17 @@ class WatchedDirectory(object):
self.callback(os.path.join(self.path,name),action) self.callback(os.path.join(self.path,name),action)
def _extract_change_info(self,buffer): def _extract_change_info(self,buffer):
"""Extract the information out of a FILE_NOTIFY_INFORMATION structure.""" """Extract the information out of a FILE_NOTIFY_INFORMATION structure."""
pos = 0 pos = 0
while pos < len(buffer): while pos < len(buffer):
jump, action, namelen = struct.unpack("iii",buffer[pos:pos+12]) jump, action, namelen = struct.unpack("iii",buffer[pos:pos+12])
# TODO: this may return a shortname or a longname, with no way # TODO: this may return a shortname or a longname, with no way
# to tell which. Normalise them somehow? # to tell which. Normalise them somehow?
name = buffer[pos+12:pos+12+namelen].decode("utf16") name = buffer[pos+12:pos+12+namelen].decode("utf16")
yield (name,action) yield (name,action)
if not jump: if not jump:
break break
pos += jump pos += jump
class WatchThread(threading.Thread): class WatchThread(threading.Thread):
...@@ -290,24 +290,24 @@ class WatchThread(threading.Thread): ...@@ -290,24 +290,24 @@ class WatchThread(threading.Thread):
flags = 0 flags = 0
for evt in events: for evt in events:
if issubclass(ACCESSED,evt): if issubclass(ACCESSED,evt):
do_access = True do_access = True
if issubclass(MODIFIED,evt): if issubclass(MODIFIED,evt):
do_change = True do_change = True
flags |= FILE_NOTIFY_CHANGE_ATTRIBUTES flags |= FILE_NOTIFY_CHANGE_ATTRIBUTES
flags |= FILE_NOTIFY_CHANGE_CREATION flags |= FILE_NOTIFY_CHANGE_CREATION
flags |= FILE_NOTIFY_CHANGE_SECURITY flags |= FILE_NOTIFY_CHANGE_SECURITY
if issubclass(CREATED,evt): if issubclass(CREATED,evt):
flags |= FILE_NOTIFY_CHANGE_FILE_NAME flags |= FILE_NOTIFY_CHANGE_FILE_NAME
flags |= FILE_NOTIFY_CHANGE_DIR_NAME flags |= FILE_NOTIFY_CHANGE_DIR_NAME
if issubclass(REMOVED,evt): if issubclass(REMOVED,evt):
flags |= FILE_NOTIFY_CHANGE_FILE_NAME flags |= FILE_NOTIFY_CHANGE_FILE_NAME
flags |= FILE_NOTIFY_CHANGE_DIR_NAME flags |= FILE_NOTIFY_CHANGE_DIR_NAME
if issubclass(MOVED_SRC,evt): if issubclass(MOVED_SRC,evt):
flags |= FILE_NOTIFY_CHANGE_FILE_NAME flags |= FILE_NOTIFY_CHANGE_FILE_NAME
flags |= FILE_NOTIFY_CHANGE_DIR_NAME flags |= FILE_NOTIFY_CHANGE_DIR_NAME
if issubclass(MOVED_DST,evt): if issubclass(MOVED_DST,evt):
flags |= FILE_NOTIFY_CHANGE_FILE_NAME flags |= FILE_NOTIFY_CHANGE_FILE_NAME
flags |= FILE_NOTIFY_CHANGE_DIR_NAME flags |= FILE_NOTIFY_CHANGE_DIR_NAME
if do_access: if do_access:
# Separately capture FILE_NOTIFY_CHANGE_LAST_ACCESS events # Separately capture FILE_NOTIFY_CHANGE_LAST_ACCESS events
# so we can reliably generate ACCESSED events. # so we can reliably generate ACCESSED events.
......
...@@ -497,7 +497,7 @@ class S3FS(FS): ...@@ -497,7 +497,7 @@ class S3FS(FS):
def removedir(self,path,recursive=False,force=False): def removedir(self,path,recursive=False,force=False):
"""Remove the directory at the given path.""" """Remove the directory at the given path."""
if normpath(path) in ('', '/'): if normpath(path) in ('', '/'):
raise DeleteRootError(path) raise RemoveRootError(path)
s3path = self._s3path(path) s3path = self._s3path(path)
if s3path != self._prefix: if s3path != self._prefix:
s3path = s3path + self._separator s3path = s3path + self._separator
......
...@@ -476,7 +476,7 @@ class SFTPFS(FS): ...@@ -476,7 +476,7 @@ class SFTPFS(FS):
def removedir(self,path,recursive=False,force=False): def removedir(self,path,recursive=False,force=False):
npath = self._normpath(path) npath = self._normpath(path)
if normpath(path) in ('', '/'): if normpath(path) in ('', '/'):
raise DeleteRootError(path) raise RemoveRootError(path)
if force: if force:
for path2 in self.listdir(path,absolute=True): for path2 in self.listdir(path,absolute=True):
try: try:
......
...@@ -841,7 +841,7 @@ class FSTestCases(object): ...@@ -841,7 +841,7 @@ class FSTestCases(object):
self.assertTrue(cmp_datetimes(d2, info['modified_time'])) self.assertTrue(cmp_datetimes(d2, info['modified_time']))
def test_removeroot(self): def test_removeroot(self):
self.assertRaises(DeleteRootError, self.fs.removedir, "/") self.assertRaises(RemoveRootError, self.fs.removedir, "/")
# May be disabled - see end of file # May be disabled - see end of file
class ThreadingTestCases(object): class ThreadingTestCases(object):
......
...@@ -20,7 +20,7 @@ import stat ...@@ -20,7 +20,7 @@ import stat
from fs.mountfs import MountFS from fs.mountfs import MountFS
from fs.path import pathjoin from fs.path import pathjoin
from fs.errors import DestinationExistsError, DeleteRootError from fs.errors import DestinationExistsError, RemoveRootError
from fs.base import FS from fs.base import FS
def copyfile(src_fs, src_path, dst_fs, dst_path, overwrite=True, chunk_size=64*1024): def copyfile(src_fs, src_path, dst_fs, dst_path, overwrite=True, chunk_size=64*1024):
...@@ -206,7 +206,7 @@ def movedir(fs1, fs2, create_destination=True, ignore_errors=False, chunk_size=6 ...@@ -206,7 +206,7 @@ def movedir(fs1, fs2, create_destination=True, ignore_errors=False, chunk_size=6
print fs1 print fs1
if parent_dir1 in ('', '/'): if parent_dir1 in ('', '/'):
raise DeleteRootError(dir1) raise RemoveRootError(dir1)
if isinstance(fs2, tuple): if isinstance(fs2, tuple):
fs2, dir2 = fs2 fs2, dir2 = fs2
......
...@@ -61,7 +61,7 @@ class SubFS(WrapFS): ...@@ -61,7 +61,7 @@ class SubFS(WrapFS):
# Careful not to recurse outside the subdir # Careful not to recurse outside the subdir
path = normpath(path) path = normpath(path)
if path in ('', '/'): if path in ('', '/'):
raise DeleteRootError(path) raise RemoveRootError(path)
super(SubFS,self).removedir(path,force=force) super(SubFS,self).removedir(path,force=force)
if recursive: if recursive:
try: try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment