Bug 1154591 - getCanStageUpdates has incorrect checks for Windows. r=spohl, a=sledru
authorRobert Strong <robert.bugzilla@gmail.com>
Fri, 17 Apr 2015 14:53:32 -0700
changeset 258524 86d3b1103197
parent 258523 b158e9bdd8a0
child 258525 e66ad17db13f
push id4688
push userrstrong@mozilla.com
push date2015-04-17 21:53 +0000
treeherdermozilla-beta@86d3b1103197 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspohl, sledru
bugs1154591
milestone38.0
Bug 1154591 - getCanStageUpdates has incorrect checks for Windows. r=spohl, a=sledru
toolkit/mozapps/update/nsUpdateService.js
--- a/toolkit/mozapps/update/nsUpdateService.js
+++ b/toolkit/mozapps/update/nsUpdateService.js
@@ -81,24 +81,16 @@ const KEY_EXECUTABLE      = "XREExeF";
 #ifdef MOZ_WIDGET_GONK
 #define USE_UPDATE_ARCHIVE_DIR
 #endif
 
 #ifdef USE_UPDATE_ARCHIVE_DIR
 const KEY_UPDATE_ARCHIVE_DIR = "UpdArchD"
 #endif
 
-#ifdef XP_WIN
-#define CHECK_CAN_USE_SERVICE
-#elifdef MOZ_WIDGET_GONK
-// In Gonk, the updater will remount the /system partition to move staged files
-// into place, so we skip the test here to keep things isolated.
-#define CHECK_CAN_USE_SERVICE
-#endif
-
 const DIR_UPDATES         = "updates";
 #ifdef XP_MACOSX
 const UPDATED_DIR         = "Updated.app";
 #else
 const UPDATED_DIR         = "updated";
 #endif
 const FILE_UPDATE_STATUS  = "update.status";
 const FILE_UPDATE_VERSION = "update.version";
@@ -716,25 +708,34 @@ XPCOMUtils.defineLazyGetter(this, "gCanA
 function getCanStageUpdates() {
   // If background updates are disabled, then just bail out!
   if (!getPref("getBoolPref", PREF_APP_UPDATE_STAGING_ENABLED, false)) {
     LOG("getCanStageUpdates - staging updates is disabled by preference " +
         PREF_APP_UPDATE_STAGING_ENABLED);
     return false;
   }
 
-#ifdef CHECK_CAN_USE_SERVICE
-  if (getPref("getBoolPref", PREF_APP_UPDATE_SERVICE_ENABLED, false)) {
+#ifdef XP_WIN
+  if (isServiceInstalled() && shouldUseService()) {
     // No need to perform directory write checks, the maintenance service will
     // be able to write to all directories.
     LOG("getCanStageUpdates - able to stage updates because we'll use the service");
     return true;
   }
 #endif
 
+#ifdef MOZ_WIDGET_GONK
+  // For Gonk, the updater will remount the /system partition to move staged
+  // files into place.
+  if (getPref("getBoolPref", PREF_APP_UPDATE_SERVICE_ENABLED, false)) {
+    LOG("getCanStageUpdates - able to stage updates because this is gonk");
+    return true;
+  }
+#endif
+
   if (!hasUpdateMutex()) {
     LOG("getCanStageUpdates - unable to apply updates because another " +
         "instance of the application is already handling updates for this " +
         "installation.");
     return false;
   }
 
   /**