Bug 1287258 - retry deletions on windows; r=ted draft
authorRob Thijssen <rthijssen@mozilla.com>
Mon, 18 Jul 2016 09:14:59 +0100
changeset 389114 b9a0e0bb07886509b53a7c5066e1af3f99c049de
parent 388920 6bcb97503de4fe93f58b4930b368b6f86650076a
child 389115 ed884270604b106dbaccdb863f13221565e0d8ce
push id23304
push userrthijssen@mozilla.com
push dateMon, 18 Jul 2016 17:03:37 +0000
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