Commit 82223948 by rfkelly0

OSFS.rename() - catch ENOTEMPTY and convert to UnsupportedError

parent 2cafbe31
...@@ -177,7 +177,16 @@ class OSFS(FS): ...@@ -177,7 +177,16 @@ class OSFS(FS):
def rename(self, src, dst): def rename(self, src, dst):
path_src = self.getsyspath(src) path_src = self.getsyspath(src)
path_dst = self.getsyspath(dst) path_dst = self.getsyspath(dst)
try:
os.rename(path_src, path_dst) os.rename(path_src, path_dst)
except OSError, e:
# Linux (at least) can rename over an empty directory but gives
# ENOTEMPTY if the dir has contents. Raise UnsupportedError
# instead of DirectoryEmptyError in this case.
if e.errno and e.errno == errno.ENOTEMPTY:
raise UnsupportedError("rename")
raise
def _stat(self,path): def _stat(self,path):
"""Stat the given path, normalising error codes.""" """Stat the given path, normalising error codes."""
......
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