simplified read-only handling again
This commit is contained in:
parent
620945da3c
commit
bf0fb3fc68
1 changed files with 2 additions and 11 deletions
|
@ -154,17 +154,8 @@ def secure_delete(path: str):
|
||||||
return
|
return
|
||||||
|
|
||||||
def del_rw(action, name, exc):
|
def del_rw(action, name, exc):
|
||||||
if not os.path.exists(name):
|
os.chmod(name, stat.S_IWRITE)
|
||||||
return
|
os.unlink(name)
|
||||||
|
|
||||||
for root, dirs, files in os.walk(name, topdown=False):
|
|
||||||
for name in files:
|
|
||||||
p = Path(os.path.join(root, name))
|
|
||||||
p.chmod(stat.S_IWRITE)
|
|
||||||
if os.path.isdir(name):
|
|
||||||
shutil.rmtree(name)
|
|
||||||
else:
|
|
||||||
os.unlink(name)
|
|
||||||
|
|
||||||
shutil.rmtree(path, onerror=del_rw)
|
shutil.rmtree(path, onerror=del_rw)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue