diff options
author | rfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f> | 2010-01-08 03:47:16 +0000 |
---|---|---|
committer | rfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f> | 2010-01-08 03:47:16 +0000 |
commit | 82223948be0ff6d8e6ca4ea296e0384675d6ae7b (patch) | |
tree | dbcb1c23a457e5a863d384a943ccfd71b158fa10 | |
parent | 2cafbe3198c601c155659d8510239c326896e24c (diff) | |
download | pyfilesystem-git-82223948be0ff6d8e6ca4ea296e0384675d6ae7b.tar.gz |
OSFS.rename() - catch ENOTEMPTY and convert to UnsupportedError
-rw-r--r-- | fs/osfs.py | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -177,7 +177,16 @@ class OSFS(FS): def rename(self, src, dst): path_src = self.getsyspath(src) path_dst = self.getsyspath(dst) - os.rename(path_src, path_dst) + try: + 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): """Stat the given path, normalising error codes.""" |