bug 1301288 - set post update values earlier in startup so Firefox post update actions can be performed. r=mhowell, a=rkothari
authorRobert Strong <robert.bugzilla@gmail.com>
Tue, 13 Sep 2016 14:37:14 -0700
changeset 348124 79429ecdadfa79a101cff2add3d5c1eac5b07e7f
parent 348123 696a981b6d534a7015d6f2ba3d2379af620e9b26
child 348125 ab5dbae4c8e22ad92ce1bffbf0198396aeb4ccfc
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhowell, rkothari
bugs1301288
milestone50.0a2
bug 1301288 - set post update values earlier in startup so Firefox post update actions can be performed. r=mhowell, a=rkothari
toolkit/mozapps/update/nsUpdateService.js
--- a/toolkit/mozapps/update/nsUpdateService.js
+++ b/toolkit/mozapps/update/nsUpdateService.js
@@ -1947,16 +1947,27 @@ UpdateService.prototype = {
    * @param   topic
    *          The notification name
    * @param   data
    *          Additional data
    */
   observe: function AUS_observe(subject, topic, data) {
     switch (topic) {
       case "post-update-processing":
+        if (readStatusFile(getUpdatesDir()) == STATE_SUCCEEDED) {
+          // The active update needs to be copied to the first update in the
+          // updates.xml early during startup to support post update actions
+          // (bug 1301288).
+          let um = Cc["@mozilla.org/updates/update-manager;1"].
+                   getService(Ci.nsIUpdateManager);
+          um.activeUpdate.state = STATE_SUCCEEDED;
+          um.saveUpdates();
+          Services.prefs.setBoolPref(PREF_APP_UPDATE_POSTUPDATE, true);
+        }
+
         if (Services.appinfo.ID in APPID_TO_TOPIC) {
           // Delay post-update processing to ensure that possible update
           // dialogs are shown in front of the app window, if possible.
           // See bug 311614.
           Services.obs.addObserver(this, APPID_TO_TOPIC[Services.appinfo.ID],
                                    false);
           break;
         }
@@ -2159,17 +2170,16 @@ UpdateService.prototype = {
       cleanUpUpdatesDir(false);
     }
 
     if (status == STATE_SUCCEEDED) {
       update.statusText = gUpdateBundle.GetStringFromName("installSuccess");
 
       // Update the patch's metadata.
       um.activeUpdate = update;
-      Services.prefs.setBoolPref(PREF_APP_UPDATE_POSTUPDATE, true);
 
       // Done with this update. Clean it up.
       cleanupActiveUpdate();
     } else if (status == STATE_PENDING_ELEVATE) {
       let prompter = Cc["@mozilla.org/updates/update-prompt;1"].
                      createInstance(Ci.nsIUpdatePrompt);
       prompter.showUpdateElevationRequired();
       return;