mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 757835 - Fall back to not use the maintenance service if there is an error when using the service to stage an update in the background; r=rstrong
This will cause us to fall back to a non-background update with a UAC prompt, which sucks, but at least it lets the user to update. --HG-- extra : transplant_source : z%00/Z%ED%E3gj%A2%E6%244%D0%B0%AE%A1zdPT
This commit is contained in:
parent
f57f0bfd53
commit
066029ac7f
@ -879,6 +879,57 @@ function readStringFromFile(file) {
|
||||
return readStringFromInputStream(fis);
|
||||
}
|
||||
|
||||
function handleUpdateFailure(update, errorCode) {
|
||||
update.errorCode = parseInt(errorCode);
|
||||
if (update.errorCode == WRITE_ERROR) {
|
||||
Cc["@mozilla.org/updates/update-prompt;1"].
|
||||
createInstance(Ci.nsIUpdatePrompt).
|
||||
showUpdateError(update);
|
||||
writeStatusFile(getUpdatesDir(), update.state = STATE_PENDING);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (update.errorCode == ELEVATION_CANCELED) {
|
||||
writeStatusFile(getUpdatesDir(), update.state = STATE_PENDING);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (update.errorCode == SERVICE_UPDATER_COULD_NOT_BE_STARTED ||
|
||||
update.errorCode == SERVICE_NOT_ENOUGH_COMMAND_LINE_ARGS ||
|
||||
update.errorCode == SERVICE_UPDATER_SIGN_ERROR ||
|
||||
update.errorCode == SERVICE_UPDATER_COMPARE_ERROR ||
|
||||
update.errorCode == SERVICE_UPDATER_IDENTITY_ERROR ||
|
||||
update.errorCode == SERVICE_STILL_APPLYING_ON_SUCCESS ||
|
||||
update.errorCode == SERVICE_STILL_APPLYING_ON_FAILURE ||
|
||||
update.errorCode == SERVICE_UPDATER_NOT_FIXED_DRIVE ||
|
||||
update.errorCode == SERVICE_COULD_NOT_LOCK_UPDATER ||
|
||||
update.errorCode == SERVICE_INSTALLDIR_ERROR) {
|
||||
|
||||
var failCount = getPref("getIntPref",
|
||||
PREF_APP_UPDATE_SERVICE_ERRORS, 0);
|
||||
var maxFail = getPref("getIntPref",
|
||||
PREF_APP_UPDATE_SERVICE_MAX_ERRORS,
|
||||
DEFAULT_SERVICE_MAX_ERRORS);
|
||||
|
||||
// As a safety, when the service reaches maximum failures, it will
|
||||
// disable itself and fallback to using the normal update mechanism
|
||||
// without the service.
|
||||
if (failCount >= maxFail) {
|
||||
Services.prefs.setBoolPref(PREF_APP_UPDATE_SERVICE_ENABLED, false);
|
||||
Services.prefs.clearUserPref(PREF_APP_UPDATE_SERVICE_ERRORS);
|
||||
} else {
|
||||
failCount++;
|
||||
Services.prefs.setIntPref(PREF_APP_UPDATE_SERVICE_ERRORS,
|
||||
failCount);
|
||||
}
|
||||
|
||||
writeStatusFile(getUpdatesDir(), update.state = STATE_PENDING);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Patch
|
||||
* @param patch
|
||||
@ -1454,48 +1505,7 @@ UpdateService.prototype = {
|
||||
var ary = status.split(":");
|
||||
update.state = ary[0];
|
||||
if (update.state == STATE_FAILED && ary[1]) {
|
||||
update.errorCode = parseInt(ary[1]);
|
||||
if (update.errorCode == WRITE_ERROR) {
|
||||
prompter.showUpdateError(update);
|
||||
writeStatusFile(getUpdatesDir(), update.state = STATE_PENDING);
|
||||
return;
|
||||
}
|
||||
|
||||
if (update.errorCode == ELEVATION_CANCELED) {
|
||||
writeStatusFile(getUpdatesDir(), update.state = STATE_PENDING);
|
||||
return;
|
||||
}
|
||||
|
||||
if (update.errorCode == SERVICE_UPDATER_COULD_NOT_BE_STARTED ||
|
||||
update.errorCode == SERVICE_NOT_ENOUGH_COMMAND_LINE_ARGS ||
|
||||
update.errorCode == SERVICE_UPDATER_SIGN_ERROR ||
|
||||
update.errorCode == SERVICE_UPDATER_COMPARE_ERROR ||
|
||||
update.errorCode == SERVICE_UPDATER_IDENTITY_ERROR ||
|
||||
update.errorCode == SERVICE_STILL_APPLYING_ON_SUCCESS ||
|
||||
update.errorCode == SERVICE_STILL_APPLYING_ON_FAILURE ||
|
||||
update.errorCode == SERVICE_UPDATER_NOT_FIXED_DRIVE ||
|
||||
update.errorCode == SERVICE_COULD_NOT_LOCK_UPDATER ||
|
||||
update.errorCode == SERVICE_INSTALLDIR_ERROR) {
|
||||
|
||||
var failCount = getPref("getIntPref",
|
||||
PREF_APP_UPDATE_SERVICE_ERRORS, 0);
|
||||
var maxFail = getPref("getIntPref",
|
||||
PREF_APP_UPDATE_SERVICE_MAX_ERRORS,
|
||||
DEFAULT_SERVICE_MAX_ERRORS);
|
||||
|
||||
// As a safety, when the service reaches maximum failures, it will
|
||||
// disable itself and fallback to using the normal update mechanism
|
||||
// without the service.
|
||||
if (failCount >= maxFail) {
|
||||
Services.prefs.setBoolPref(PREF_APP_UPDATE_SERVICE_ENABLED, false);
|
||||
Services.prefs.clearUserPref(PREF_APP_UPDATE_SERVICE_ERRORS);
|
||||
} else {
|
||||
failCount++;
|
||||
Services.prefs.setIntPref(PREF_APP_UPDATE_SERVICE_ERRORS,
|
||||
failCount);
|
||||
}
|
||||
|
||||
writeStatusFile(getUpdatesDir(), update.state = STATE_PENDING);
|
||||
if (handleUpdateFailure(update, ary[1])) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2315,11 +2325,13 @@ UpdateManager.prototype = {
|
||||
},
|
||||
|
||||
refreshUpdateStatus: function UM_refreshUpdateStatus(update) {
|
||||
var updateSucceeded = true;
|
||||
var status = readStatusFile(getUpdatesDir());
|
||||
var ary = status.split(":");
|
||||
update.state = ary[0];
|
||||
if (update.state == STATE_FAILED && ary[1]) {
|
||||
update.errorCode = parseInt(ary[1]);
|
||||
updateSucceeded = false;
|
||||
handleUpdateFailure(update, ary[1]);
|
||||
}
|
||||
if (update.state == STATE_APPLIED && shouldUseService()) {
|
||||
writeStatusFile(getUpdatesDir(), update.state = STATE_APPLIED_SVC);
|
||||
@ -2329,7 +2341,7 @@ UpdateManager.prototype = {
|
||||
um.saveUpdates();
|
||||
|
||||
// Destroy the updates directory, since we're done with it.
|
||||
cleanUpUpdatesDir(true);
|
||||
cleanUpUpdatesDir(updateSucceeded);
|
||||
|
||||
// Send an observer notification which the update wizard uses in
|
||||
// order to update its UI.
|
||||
|
Loading…
Reference in New Issue
Block a user