Commit d74ba1ec by rfkelly0

removedir(force=True): guard against new files being created in the target dir

parent fdeae943
...@@ -116,7 +116,13 @@ class OSFS(FS): ...@@ -116,7 +116,13 @@ class OSFS(FS):
# Don't remove the root directory of this FS # Don't remove the root directory of this FS
if path in ("","/"): if path in ("","/"):
return return
os.rmdir(sys_path) try:
os.rmdir(sys_path)
except OSError, e:
if e.errno != errno.ENOTEMPTY or not force:
raise
# Someone has created files in here in the meantime, try again.
self.removedir(path,recursive=False,force=True)
# 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.
if recursive: if recursive:
......
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