aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mesonlib
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2021-03-25 11:25:37 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2021-03-26 18:12:35 +0200
commit64775c0fd335c53604a295426d9d6ab4aae24cf8 (patch)
tree81dd7d525f6d4c7605c509a75d0bd2318442d013 /mesonbuild/mesonlib
parent56c03e1517bee43b6aa373c9e81beda1fd05b945 (diff)
downloadmeson-64775c0fd335c53604a295426d9d6ab4aae24cf8.zip
meson-64775c0fd335c53604a295426d9d6ab4aae24cf8.tar.gz
meson-64775c0fd335c53604a295426d9d6ab4aae24cf8.tar.bz2
windows_proof_rmtree: Also retry os.chmod() part
It looks like when Windows media scanner holds files we can't change their permission neither.
Diffstat (limited to 'mesonbuild/mesonlib')
-rw-r--r--mesonbuild/mesonlib/universal.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/mesonbuild/mesonlib/universal.py b/mesonbuild/mesonlib/universal.py
index b0b987e..45c3e5c 100644
--- a/mesonbuild/mesonlib/universal.py
+++ b/mesonbuild/mesonlib/universal.py
@@ -1530,10 +1530,17 @@ def windows_proof_rmtree(f: str) -> None:
# be scanning files you are trying to delete. The only
# way to fix this is to try again and again.
delays = [0.1, 0.1, 0.2, 0.2, 0.2, 0.5, 0.5, 1, 1, 1, 1, 2]
- # Start by making the tree wriable.
- _make_tree_writable(f)
+ writable = False
for d in delays:
try:
+ # Start by making the tree writable.
+ if not writable:
+ _make_tree_writable(f)
+ writable = True
+ except PermissionError:
+ time.sleep(d)
+ continue
+ try:
shutil.rmtree(f)
return
except FileNotFoundError: