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
|
||||
|
||||
def del_rw(action, name, exc):
|
||||
if not os.path.exists(name):
|
||||
return
|
||||
|
||||
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)
|
||||
os.chmod(name, stat.S_IWRITE)
|
||||
os.unlink(name)
|
||||
|
||||
shutil.rmtree(path, onerror=del_rw)
|
||||
|
||||
|
|
Loading…
Reference in a new issue