Bug 1287258 - retry deletions on windows; r=ted
authorRob Thijssen <rthijssen@mozilla.com>
Mon, 18 Jul 2016 09:14:59 +0100
changeset 330769 f93d6b4f79366c35f92908f5436fae7eda7cf050
parent 330768 8df802dec5fbf1e04401e87a15acd2a04bff7680
child 330770 70b550c1b6d1f6934a987bf8042683a83d92b081
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs1287258
milestone50.0a1
Bug 1287258 - retry deletions on windows; r=ted MozReview-Commit-ID: KObLa5RsjFW
config/nsinstall.py
--- a/config/nsinstall.py
+++ b/config/nsinstall.py
@@ -6,16 +6,17 @@
 # It's intended to be used when there's no natively compile nsinstall
 # available, and doesn't intend to be fully equivalent.
 # Its major use is for l10n repackaging on systems that don't have
 # a full build environment set up.
 # The basic limitation is, it doesn't even try to link and ignores
 # all related options.
 from __future__ import print_function
 from optparse import OptionParser
+import mozfile
 import os
 import os.path
 import sys
 import shutil
 import stat
 
 def _nsinstall_internal(argv):
   usage = "usage: %prog [options] arg1 [arg2 ...] target-directory"
@@ -121,20 +122,20 @@ def _nsinstall_internal(argv):
           os.mkdir(targetpath)
         entries = [os.path.join(srcpath, e) for e in os.listdir(srcpath)]
         copy_all_entries(entries, targetpath)
         # options.t is not relevant for directories
         if options.m:
           os.chmod(targetpath, options.m)
       else:
         if os.path.exists(targetpath):
-          # On Windows, read-only files can't be deleted
           if sys.platform == "win32":
-            os.chmod(targetpath, stat.S_IWUSR)
-          os.remove(targetpath)
+            mozfile.remove(targetpath)
+          else:
+            os.remove(targetpath)
         if options.t:
           shutil.copy2(srcpath, targetpath)
         else:
           shutil.copy(srcpath, targetpath)
 
   # the last argument is the target directory
   target = args.pop()
   # ensure target directory (importantly, we do not apply a mode to the directory