[tor-commits] [tor-browser/esr24] Bug 925747 - Patch file extraction cleanup. r=bbondy, a=sledru

mikeperry at torproject.org mikeperry at torproject.org
Fri Aug 29 05:26:37 UTC 2014


commit 6ff583446d721fdda2c272fb0d6ee108427c4304
Author: Robert Strong <robert.bugzilla at gmail.com>
Date:   Mon Jan 27 10:50:54 2014 -0800

    Bug 925747 - Patch file extraction cleanup. r=bbondy, a=sledru
---
 .../macbuild/Contents/_CodeSignature/CodeResources |   12 ++++++++++
 toolkit/mozapps/update/test/unit/head_update.js.in |   23 ++++++++++++++++++++
 toolkit/mozapps/update/updater/updater.cpp         |   10 +++++++--
 3 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/browser/app/macbuild/Contents/_CodeSignature/CodeResources b/browser/app/macbuild/Contents/_CodeSignature/CodeResources
index 22666b9..6f6e20e 100644
--- a/browser/app/macbuild/Contents/_CodeSignature/CodeResources
+++ b/browser/app/macbuild/Contents/_CodeSignature/CodeResources
@@ -54,6 +54,18 @@
                 <key>weight</key>
                 <real>10</real>
             </dict>
+            <key>^Updated.app/.*</key><dict>
+                <key>omit</key>
+                <true/>
+                <key>weight</key>
+                <real>10</real>
+            </dict>
+            <key>^updating/.*</key><dict>
+                <key>omit</key>
+                <true/>
+                <key>weight</key>
+                <real>10</real>
+            </dict>
         </dict>
     </dict>
 </plist>
diff --git a/toolkit/mozapps/update/test/unit/head_update.js.in b/toolkit/mozapps/update/test/unit/head_update.js.in
index 974afa4..68a19e1 100644
--- a/toolkit/mozapps/update/test/unit/head_update.js.in
+++ b/toolkit/mozapps/update/test/unit/head_update.js.in
@@ -424,6 +424,22 @@ function getUpdatedDirPath() {
 }
 
 /**
+ * Helper function for getting the updating directory which is used by the
+ * updater to extract the update manifest and patch files.
+ *
+ * @return  nsIFile for the directory for the updating directory.
+ */
+function getUpdatingDir() {
+  let updatingDir = getApplyDirFile(null, true);
+
+  if (IS_MACOSX) {
+    updatingDir = updatingDir.parent.parent;
+  }
+  updatingDir.append("updating");
+  return updatingDir;
+}
+
+/**
  * Helper function for getting the nsIFile for the directory where the update
  * has been applied.
  *
@@ -650,6 +666,9 @@ function runUpdate() {
     updateSettingsIni.moveTo(updateSettingsIni.parent, FILE_UPDATE_SETTINGS_INI);
   }
 
+  logTestInfo("testing updating directory doesn't exist");
+  do_check_false(getUpdatingDir().exists());
+
   return process.exitValue;
 }
 
@@ -1015,6 +1034,10 @@ function runUpdateUsingService(aInitialStatus, aExpectedStatus,
     if (aCheckSvcLog) {
       checkServiceLogs(svcOriginalLog);
     } 
+
+    logTestInfo("testing updating directory doesn't exist");
+    do_check_false(getUpdatingDir().exists());
+
     aCallback();
   }
 
diff --git a/toolkit/mozapps/update/updater/updater.cpp b/toolkit/mozapps/update/updater/updater.cpp
index eae3ce3..927f77e 100644
--- a/toolkit/mozapps/update/updater/updater.cpp
+++ b/toolkit/mozapps/update/updater/updater.cpp
@@ -1394,7 +1394,7 @@ PatchFile::Prepare()
   mPatchIndex = sPatchIndex++;
 
   NS_tsnprintf(spath, sizeof(spath)/sizeof(spath[0]),
-               NS_T("%s/%d.patch"), gSourcePath, mPatchIndex);
+               NS_T("%s/updating/%d.patch"), gDestinationPath, mPatchIndex);
 
   NS_tremove(spath);
 
@@ -2230,6 +2230,10 @@ UpdateThreadFunc(void *param)
     if (rv == OK) {
       rv = DoUpdate();
       gArchiveReader.Close();
+      NS_tchar updatingDir[MAXPATHLEN];
+      NS_tsnprintf(updatingDir, sizeof(updatingDir)/sizeof(updatingDir[0]),
+                   NS_T("%s/updating"), gDestinationPath);
+      ensure_remove_recursive(updatingDir);
     }
   }
 
@@ -3644,7 +3648,8 @@ int DoUpdate()
 {
   NS_tchar manifest[MAXPATHLEN];
   NS_tsnprintf(manifest, sizeof(manifest)/sizeof(manifest[0]),
-               NS_T("%s/update.manifest"), gSourcePath);
+               NS_T("%s/updating/update.manifest"), gDestinationPath);
+  ensure_parent_dir(manifest);
 
   // extract the manifest
   int rv = gArchiveReader.ExtractFile("updatev2.manifest", manifest);
@@ -3657,6 +3662,7 @@ int DoUpdate()
   }
 
   NS_tchar *rb = GetManifestContents(manifest);
+  NS_tremove(manifest);
   if (rb == NULL) {
     LOG(("DoUpdate: error opening manifest file: " LOG_S, manifest));
     return READ_ERROR;





More information about the tor-commits mailing list