Skip to content
Snippets Groups Projects
Verified Commit 99c0a788 authored by Mattia Rizzolo's avatar Mattia Rizzolo
Browse files

tempfiles: save a bunch of syscalls, by resetting the permissions only when we...

tempfiles: save a bunch of syscalls, by resetting the permissions only when we actually need to do it.

Signed-off-by: Mattia Rizzolo's avatarMattia Rizzolo <mattia@debian.org>
parent 7345efa0
No related branches found
No related tags found
No related merge requests found
......@@ -58,15 +58,17 @@ def clean_all_temp_files():
logger.debug("Cleaning %d temporary directories", len(_DIRS))
for x in _DIRS:
# Recursively reset the permissions of temporary directories prior to
# deletion to ensure that non-writable permissions such as 0555 are
# removed and do not cause a traceback. (#891363)
for dirpath, ys, _ in os.walk(x.name):
for y in ys:
os.chmod(os.path.join(dirpath, y), 0o777)
try:
x.cleanup()
except PermissionError:
# Recursively reset the permissions of temporary directories prior to
# deletion to ensure that non-writable permissions such as 0555 are
# removed and do not cause a traceback. (#891363)
for dirpath, ys, _ in os.walk(x.name):
for y in ys:
os.chmod(os.path.join(dirpath, y), 0o777)
# try removing it again now
x.cleanup()
except FileNotFoundError:
pass
except:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment