[PATCH] D45345: [annotated_builder] try harder to clean build directories
Bob Haarman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 9 16:09:23 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329637: [annotated_builder] try harder to clean build directories (authored by inglorion, committed by ).
Repository:
rL LLVM
https://reviews.llvm.org/D45345
Files:
zorg/trunk/zorg/buildbot/builders/annotated/util.py
Index: zorg/trunk/zorg/buildbot/builders/annotated/util.py
===================================================================
--- zorg/trunk/zorg/buildbot/builders/annotated/util.py
+++ zorg/trunk/zorg/buildbot/builders/annotated/util.py
@@ -10,11 +10,11 @@
def clean_dir(path):
"""
- Remove directory path if it exists and create a new, empty directory
- in its place.
+ Removes directory at path (and all its subdirectories) if it exists,
+ and creates an empty directory in its place.
"""
try:
- shutil.rmtree(path)
+ rmtree(path)
except OSError as e:
if e.errno != errno.ENOENT:
raise
@@ -58,6 +58,24 @@
raise
+def rmtree(path):
+ """
+ Remove directory path and all its subdirectories. This differs from
+ shutil.rmtree() in that it tries to adjust permissions so that deletion
+ will succeed.
+ """
+ # Some files will not be deletable, so we set permissions that allow
+ # deletion before we try deleting files.
+ for root, dirs, files in os.walk(path):
+ os.chmod(root, 0o755)
+ for f in files:
+ p = os.path.join(root, f)
+ os.chmod(p, 0o644)
+ os.unlink(p)
+ # At this point, we should have a tree of deletable directories.
+ shutil.rmtree(path)
+
+
def safe_pjoin(dirname, *args):
"""
Join path components with os.path.join, skipping the first component
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45345.141764.patch
Type: text/x-patch
Size: 1442 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180409/fcd051ab/attachment.bin>
More information about the llvm-commits
mailing list