Bug 1147760 - In mozpack.files.FileCopier.copy, remove files after copying. r=gps, a=sledru
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 26 Mar 2015 15:40:08 +0900
changeset 266871 f6c18d1052d6b1a160597e570345ee24b83807bb
parent 266870 cd483f7d9dc8e776f1028826cbe1e4d7e17e58c5
child 266872 4490c3a031bc7de2fa5518e73e90f067650164e8
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps, sledru
bugs1147760
milestone39.0a2
Bug 1147760 - In mozpack.files.FileCopier.copy, remove files after copying. r=gps, a=sledru Some file types, such as XPTFile, read their associated data during the copy. In the case of XPTFiles, several original files are linked together in one destination file. When a FileCopier is used in-place, those original files are removed before XPTFile.copy is invoked, so XPTFile.copy fails. Generally speaking, there are many other reasons why FileCopier can fail in-place, but the only active use of this mode is l10n repack code, which actually doesn't do much of the dangerous uses. However, it can end up linking XPTFiles for some reason, which fails for the reasons given above.
python/mozbuild/mozpack/copier.py
--- a/python/mozbuild/mozpack/copier.py
+++ b/python/mozbuild/mozpack/copier.py
@@ -310,36 +310,36 @@ class FileCopier(FileRegistry):
             for d in dirs:
                 existing_dirs.add(os.path.normpath(os.path.join(root, d)))
 
             for f in files:
                 existing_files.add(os.path.normpath(os.path.join(root, f)))
 
         # Now we reconcile the state of the world against what we want.
 
+        # Install files.
+        for p, f in self:
+            destfile = os.path.normpath(os.path.join(destination, p))
+            if f.copy(destfile, skip_if_older):
+                result.updated_files.add(destfile)
+            else:
+                result.existing_files.add(destfile)
+
         # Remove files no longer accounted for.
         if remove_unaccounted:
             for f in existing_files - dest_files:
                 # Windows requires write access to remove files.
                 if os.name == 'nt' and not os.access(f, os.W_OK):
                     # It doesn't matter what we set permissions to since we
                     # will remove this file shortly.
                     os.chmod(f, 0600)
 
                 os.remove(f)
                 result.removed_files.add(f)
 
-        # Install files.
-        for p, f in self:
-            destfile = os.path.normpath(os.path.join(destination, p))
-            if f.copy(destfile, skip_if_older):
-                result.updated_files.add(destfile)
-            else:
-                result.existing_files.add(destfile)
-
         if not remove_empty_directories:
             return result
 
         # Figure out which directories can be removed. This is complicated
         # by the fact we optionally remove existing files. This would be easy
         # if we walked the directory tree after installing files. But, we're
         # trying to minimize system calls.