зеркало из https://github.com/mozilla/pjs.git
Bug 536547 - 3.5.6 is downloading the same version for an update. This prevents resuming the download for an update with the same app version with the same build id.. r=dolske
This commit is contained in:
Родитель
e12549b1df
Коммит
8037db8fb8
|
@ -125,6 +125,10 @@ XPCOMUtils.defineLazyServiceGetter(this, "gConsole",
|
|||
"@mozilla.org/consoleservice;1",
|
||||
"nsIConsoleService");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gVC",
|
||||
"@mozilla.org/xpcom/version-comparator;1",
|
||||
"nsIVersionComparator");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "gApp", function aus_gApp() {
|
||||
return Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo).
|
||||
QueryInterface(Ci.nsIXULRuntime);
|
||||
|
@ -1252,17 +1256,15 @@ UpdateService.prototype = {
|
|||
var majorUpdate = null, minorUpdate = null;
|
||||
var newestMinor = updates[0], newestMajor = updates[0];
|
||||
|
||||
var vc = Cc["@mozilla.org/xpcom/version-comparator;1"].
|
||||
getService(Ci.nsIVersionComparator);
|
||||
for (var i = 0; i < updates.length; ++i) {
|
||||
// Ignore updates for older versions of the application
|
||||
if (vc.compare(updates[i].extensionVersion, gApp.version) < 0)
|
||||
if (gVC.compare(updates[i].extensionVersion, gApp.version) < 0)
|
||||
continue;
|
||||
if (updates[i].type == "major" &&
|
||||
vc.compare(newestMajor.version, updates[i].version) <= 0)
|
||||
gVC.compare(newestMajor.version, updates[i].version) <= 0)
|
||||
majorUpdate = newestMajor = updates[i];
|
||||
if (updates[i].type == "minor" &&
|
||||
vc.compare(newestMinor.version, updates[i].version) <= 0)
|
||||
gVC.compare(newestMinor.version, updates[i].version) <= 0)
|
||||
minorUpdate = newestMinor = updates[i];
|
||||
}
|
||||
|
||||
|
@ -1390,12 +1392,9 @@ UpdateService.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
var ai = Cc["@mozilla.org/xre/app-info;1"].
|
||||
getService(Ci.nsIXULAppInfo);
|
||||
var vc = Cc["@mozilla.org/xpcom/version-comparator;1"].
|
||||
getService(Ci.nsIVersionComparator);
|
||||
// Only check add-on compatibility when the version changes.
|
||||
if (update.extensionVersion &&
|
||||
vc.compare(update.extensionVersion, ai.version) != 0) {
|
||||
gVC.compare(update.extensionVersion, gApp.version) != 0) {
|
||||
this._update = update;
|
||||
this._checkAddonCompatibility();
|
||||
}
|
||||
|
@ -1583,16 +1582,20 @@ UpdateService.prototype = {
|
|||
if (!update)
|
||||
throw Cr.NS_ERROR_NULL_POINTER;
|
||||
|
||||
let ai = Cc["@mozilla.org/xre/app-info;1"].
|
||||
getService(Ci.nsIXULAppInfo);
|
||||
let vc = Cc["@mozilla.org/xpcom/version-comparator;1"].
|
||||
getService(Ci.nsIVersionComparator);
|
||||
// Don't download the update if the update's version is less than the
|
||||
// current application's version.
|
||||
// current application's version or the update's version is the same as the
|
||||
// application's version and the build ID is the same as the application's
|
||||
// build ID.
|
||||
if (update.extensionVersion &&
|
||||
vc.compare(update.extensionVersion, ai.version) < 0) {
|
||||
LOG("UpdateService:downloadUpdate - removing update for previous " +
|
||||
"application version " + update.extensionVersion);
|
||||
(gVC.compare(update.extensionVersion, gApp.version) < 0 ||
|
||||
update.buildID && update.buildID == gApp.appBuildID &&
|
||||
update.extensionVersion == gApp.version)) {
|
||||
LOG("UpdateService:downloadUpdate - canceling download of update since " +
|
||||
"it is for an earlier or same application version and build ID.\n" +
|
||||
"current application version: " + gApp.version + "\n" +
|
||||
"update application version : " + update.extensionVersion + "\n" +
|
||||
"current build ID: " + gApp.buildID + "\n" +
|
||||
"update build ID : " + update.buildID);
|
||||
cleanupActiveUpdate();
|
||||
return STATE_NONE;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Application Update Service.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Robert Strong <robert.bugzilla@gmail.com>.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Mozilla Foundation <http://www.mozilla.org/>. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/* General Update Manager Tests */
|
||||
|
||||
function run_test() {
|
||||
dump("Testing: removal of an update download in progress for the same " +
|
||||
"version of the application with the same application build id on " +
|
||||
"startup - bug 536547\n");
|
||||
removeUpdateDirsAndFiles();
|
||||
var defaults = getPrefBranch().QueryInterface(AUS_Ci.nsIPrefService).
|
||||
getDefaultBranch(null);
|
||||
defaults.setCharPref("app.update.channel", "bogus_channel");
|
||||
|
||||
writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
|
||||
|
||||
var patches = getLocalPatchString(null, null, null, null, null, null,
|
||||
STATE_DOWNLOADING);
|
||||
var updates = getLocalUpdateString(patches, null, null, "1.0", null, "1.0",
|
||||
"2007010101");
|
||||
writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
|
||||
writeStatusFile(STATE_DOWNLOADING);
|
||||
|
||||
startAUS();
|
||||
startUpdateManager();
|
||||
|
||||
do_check_eq(gUpdateManager.activeUpdate, null);
|
||||
do_check_eq(gUpdateManager.updateCount, 0);
|
||||
cleanUp();
|
||||
}
|
Загрузка…
Ссылка в новой задаче