Commit 9a9765e5 by rfkelly0

OSFS: improve robustness of removedir(force=True)

parent a7eb9b1f
...@@ -90,9 +90,15 @@ class OSFS(FS): ...@@ -90,9 +90,15 @@ class OSFS(FS):
sys_path = self.getsyspath(path) sys_path = self.getsyspath(path)
if force: if force:
for path2 in self.listdir(path,absolute=True,files_only=True): for path2 in self.listdir(path,absolute=True,files_only=True):
self.remove(path2) try:
self.remove(path2)
except ResourceNotFoundError:
pass
for path2 in self.listdir(path,absolute=True,dirs_only=True): for path2 in self.listdir(path,absolute=True,dirs_only=True):
self.removedir(path2,force=True) try:
self.removedir(path2,force=True)
except ResourceNotFoundError:
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 ("","/"):
return return
......
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