Bug 1287258 - retry deletions on windows; r=ted
authorRob Thijssen <rthijssen@mozilla.com>
Mon, 18 Jul 2016 09:14:59 +0100
changeset 389615 f93d6b4f79366c35f92908f5436fae7eda7cf050
parent 389614 8df802dec5fbf1e04401e87a15acd2a04bff7680
child 389616 70b550c1b6d1f6934a987bf8042683a83d92b081
push id23471
push userbmo:tchiovoloni@mozilla.com
push dateTue, 19 Jul 2016 18:52:45 +0000
Bug 1287258 - retry deletions on windows; r=ted MozReview-Commit-ID: KObLa5RsjFW
--- 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):
         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)
         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)
           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