Bug 759615 - Avoid running the PostUpdate step when only staging the update in the background; r=rstrong
--- a/toolkit/components/maintenanceservice/workmonitor.cpp
+++ b/toolkit/components/maintenanceservice/workmonitor.cpp
@@ -234,27 +234,33 @@ StartUpdateProcess(int argc,
// of error so that the normal update process can use it.
if (selfHandlePostUpdate) {
MoveFileExW(updaterINITemp, updaterINI, MOVEFILE_REPLACE_EXISTING);
// Only run the PostUpdate if the update was successful
if (updateWasSuccessful && argc > 2) {
LPCWSTR installationDir = argv[2];
LPCWSTR updateInfoDir = argv[1];
+ bool backgroundUpdate = (argc == 4 && !wcscmp(argv[3], L"-1"));
// Launch the PostProcess with admin access in session 0. This is
// actually launching the post update process but it takes in the
// callback app path to figure out where to apply to.
// The PostUpdate process with user only access will be done inside
// the unelevated updater.exe after the update process is complete
// from the service. We don't know here which session to start
// the user PostUpdate process from.
- LOG(("Launching post update process as the service in session 0.\n"));
- if (!LaunchWinPostProcess(installationDir, updateInfoDir, true, NULL)) {
- LOG(("The post update process could not be launched.\n"));
+ // Note that we don't need to do this if we're just staging the
+ // update in the background, as the PostUpdate step runs when
+ // performing the replacing in that case.
+ if (!backgroundUpdate) {
+ LOG(("Launching post update process as the service in session 0.\n"));
+ if (!LaunchWinPostProcess(installationDir, updateInfoDir, true, NULL)) {
+ LOG(("The post update process could not be launched.\n"));
+ }
}
}
}
free(cmdLine);
return updateWasSuccessful;
}
--- a/toolkit/mozapps/update/updater/updater.cpp
+++ b/toolkit/mozapps/update/updater/updater.cpp
@@ -2423,17 +2423,20 @@ int NS_main(int argc, NS_tchar **argv)
return 0;
}
// If we started the service command, and it finished, check the
// update.status file to make sure it succeeded, and if it did
// we need to manually start the PostUpdate process from the
// current user's session of this unelevated updater.exe the
// current process is running as.
- if (useService) {
+ // Note that we don't need to do this if we're just staging the
+ // update in the background, as the PostUpdate step runs when
+ // performing the replacing in that case.
+ if (useService && !sBackgroundUpdate) {
bool updateStatusSucceeded = false;
if (IsUpdateStatusSucceeded(updateStatusSucceeded) &&
updateStatusSucceeded) {
if (!LaunchWinPostProcess(installDir, gSourcePath, false, NULL)) {
fprintf(stderr, "The post update process which runs as the user"
" for service update could not be launched.");
}
}
@@ -2746,22 +2749,22 @@ int NS_main(int argc, NS_tchar **argv)
// The service update will only be executed if it is already installed.
// For first time installs of the service, the install will happen from
// the PostUpdate process. We do the service update process here
// because it's possible we are updating with updater.exe without the
// service if the service failed to apply the update. We want to update
// the service to a newer version in that case. If we are not running
// through the service, then MOZ_USING_SERVICE will not exist.
if (!usingService) {
- if (!LaunchWinPostProcess(argv[callbackIndex], gSourcePath, false, NULL)) {
- LOG(("NS_main: The post update process could not be launched.\n"));
- }
-
NS_tchar installDir[MAXPATHLEN];
if (GetInstallationDir(installDir)) {
+ if (!LaunchWinPostProcess(installDir, gSourcePath, false, NULL)) {
+ LOG(("NS_main: The post update process could not be launched.\n"));
+ }
+
StartServiceUpdate(installDir);
}
}
}
EXIT_WHEN_ELEVATED(elevatedLockFilePath, updateLockFileHandle, 0);
#endif /* XP_WIN */
#ifdef XP_MACOSX
if (gSucceeded) {