mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-09 20:58:54 -05:00
[Utils] Modify chmod use in safe_delete (#2701)
- Takes a pessmisitc approach that it's possible chmod succeeds, but deletion fails and does not make the entire dir world writeable
This commit is contained in:
parent
8bf86f33a3
commit
8a72840de0
@ -62,13 +62,13 @@ logging.getLogger().addFilter(_fuzzy_log_filter)
|
||||
def safe_delete(pth: Path):
|
||||
if pth.exists():
|
||||
for root, dirs, files in os.walk(str(pth)):
|
||||
os.chmod(root, 0o755)
|
||||
os.chmod(root, 0o700)
|
||||
|
||||
for d in dirs:
|
||||
os.chmod(os.path.join(root, d), 0o755)
|
||||
os.chmod(os.path.join(root, d), 0o700)
|
||||
|
||||
for f in files:
|
||||
os.chmod(os.path.join(root, f), 0o755)
|
||||
os.chmod(os.path.join(root, f), 0o700)
|
||||
|
||||
shutil.rmtree(str(pth), ignore_errors=True)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user