author | Robert Strong <robert.bugzilla@gmail.com> |
Thu, 13 Jan 2011 11:36:28 -0800 | |
changeset 60454 | 46446fa861b5bf99eb84b0e8555422fdddaa7b68 |
parent 60453 | 1511d70f1e4229732089b14b95b46626a93cdf46 |
child 60455 | fe1ce4c8c5cf43e0528fa5b2fb174a98a3b30464 |
push id | 17998 |
push user | rstrong@mozilla.com |
push date | Thu, 13 Jan 2011 19:36:47 +0000 |
treeherder | mozilla-central@fe1ce4c8c5cf [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mossop, blocking2.0-final |
bugs | 601701 |
milestone | 2.0b10pre |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/toolkit/mozapps/update/nsUpdateService.js +++ b/toolkit/mozapps/update/nsUpdateService.js @@ -1752,18 +1752,28 @@ UpdateService.prototype = { /** * A service to manage active and past updates. * @constructor */ function UpdateManager() { // Ensure the Active Update file is loaded var updates = this._loadXMLFileIntoArray(getUpdateFile( [FILE_UPDATE_ACTIVE])); - if (updates.length > 0) - this._activeUpdate = updates[0]; + if (updates.length > 0) { + // Under some edgecases such as Windows system restore the active-update.xml + // will contain a pending update without the status file which will return + // STATE_NONE. To recover from this situation clean the updates dir and + // rewrite the active-update.xml file without the broken update. + if (readStatusFile(getUpdatesDir()) == STATE_NONE) { + cleanUpUpdatesDir(); + this._writeUpdatesToXMLFile([], getUpdateFile([FILE_UPDATE_ACTIVE])); + } + else + this._activeUpdate = updates[0]; + } } UpdateManager.prototype = { /** * All previously downloaded and installed updates, as an array of nsIUpdate * objects. */ _updates: null,
new file mode 100644 --- /dev/null +++ b/toolkit/mozapps/update/test/unit/test_0073_update_dir_cleanup.js @@ -0,0 +1,43 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +/* General Update Directory Cleanup Tests - Bug 601701 */ + +function run_test() { + do_test_pending(); + do_register_cleanup(end_test); + + removeUpdateDirsAndFiles(); + setUpdateChannel(); + + writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false); + var patches = getLocalPatchString(null, null, null, null, null, null, + STATE_PENDING); + var updates = getLocalUpdateString(patches); + writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true); + writeVersionFile("99.9"); + + standardInit(); + + // Check that there is no activeUpdate first so the updates directory is + // cleaned before the remaining tests. + do_check_eq(gUpdateManager.activeUpdate, null); + do_check_eq(gUpdateManager.updateCount, 0); + + var dir = getUpdatesDir(); + dir.append("0"); + logTestInfo("testing " + dir.path + " should exist"); + do_check_true(dir.exists()); + + var versionFile = dir.clone(); + versionFile.append(FILE_UPDATE_VERSION); + logTestInfo("testing " + versionFile.path + " should not exist"); + do_check_false(versionFile.exists()); + + do_test_finished(); +} + +function end_test() { + cleanUp(); +}