aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/util.py
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2018-03-08 09:50:51 -0500
committerJosh Matthews <josh@joshmatthews.net>2018-03-08 11:13:06 -0500
commit71e2e84ce8c344d839dd75d4ab1252b81679a083 (patch)
tree758574dd52de598b439ae1c97607971f68f7349a /python/servo/util.py
parent1d122c250c906358a91b607b0fcc720546d04134 (diff)
downloadservo-71e2e84ce8c344d839dd75d4ab1252b81679a083.tar.gz
servo-71e2e84ce8c344d839dd75d4ab1252b81679a083.zip
Ensure readonly files can be removed on Windows.
Diffstat (limited to 'python/servo/util.py')
-rw-r--r--python/servo/util.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/python/servo/util.py b/python/servo/util.py
index 66f2f11527c..2043b0e2868 100644
--- a/python/servo/util.py
+++ b/python/servo/util.py
@@ -14,6 +14,7 @@ import os.path
import platform
import shutil
from socket import error as socket_error
+import stat
import StringIO
import sys
import zipfile
@@ -35,9 +36,15 @@ else:
URLOPEN_KWARGS = {}
+def remove_readonly(func, path, _):
+ "Clear the readonly bit and reattempt the removal"
+ os.chmod(path, stat.S_IWRITE)
+ func(path)
+
+
def delete(path):
if os.path.isdir(path) and not os.path.islink(path):
- shutil.rmtree(path)
+ shutil.rmtree(path, onerror=remove_readonly)
else:
os.remove(path)