Bug 841631 - [Intermittent] Large Packaged App Downloads on Weak Connections can have HTTP requests stopped in the middle of download, which results in a corrupted package download; r=fabrice
authorFernando Jiménez <ferjmoreno@gmail.com>
Tue, 19 Feb 2013 09:39:53 +0100
changeset 132180 dc90a0618dd20d0a06510109fa02816a76ffbafb
parent 132179 caa9e261c08ce342f7fb79f7d34437f0e4e16ede
child 132181 a7a57be02f88b21de5d586a5fc059565996ced7e
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice
bugs841631
milestone21.0a1
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
Bug 841631 - [Intermittent] Large Packaged App Downloads on Weak Connections can have HTTP requests stopped in the middle of download, which results in a corrupted package download; r=fabrice
dom/apps/src/Webapps.jsm
--- a/dom/apps/src/Webapps.jsm
+++ b/dom/apps/src/Webapps.jsm
@@ -2247,16 +2247,18 @@ this.DOMApplicationRegistry = {
 
             certdb.openSignedJARFileAsync(zipFile, function(aRv, aZipReader) {
               let zipReader;
               try {
                 let isSigned;
                 if (Components.isSuccessCode(aRv)) {
                   isSigned = true;
                   zipReader = aZipReader;
+                } else if (aRv == Cr.NS_ERROR_FILE_CORRUPTED) {
+                  throw "APP_PACKAGE_CORRUPTED";
                 } else if (aRv != Cr.NS_ERROR_SIGNED_JAR_NOT_SIGNED) {
                   throw "INVALID_SIGNATURE";
                 } else {
                   isSigned = false;
                   zipReader = Cc["@mozilla.org/libjar/zip-reader;1"]
                                 .createInstance(Ci.nsIZipReader);
                   zipReader.open(zipFile);
                 }
@@ -2283,17 +2285,17 @@ this.DOMApplicationRegistry = {
                 let isSignedAppOrigin
                   = signedAppOriginsStr.split(",").indexOf(aApp.installOrigin) > -1;
                 if (!isSigned && isSignedAppOrigin) {
                   // Packaged apps installed from these origins must be signed;
                   // if not, assume somebody stripped the signature.
                   throw "INVALID_SIGNATURE";
                 } else if (isSigned && !isSignedAppOrigin) {
                   // Other origins are *prohibited* from installing signed apps.
-                  // One reason is that our app revociation mechanism requires
+                  // One reason is that our app revocation mechanism requires
                   // strong cooperation from the host of the mini-manifest, which
                   // we assume to be under the control of the install origin,
                   // even if it has a different origin.
                   throw "INSTALL_FROM_DENIED";
                 }
 
                 if (!zipReader.hasEntry("manifest.webapp")) {
                   throw "MISSING_MANIFEST";
@@ -2354,18 +2356,23 @@ this.DOMApplicationRegistry = {
                   app.appStatus = AppsUtils.getAppManifestStatus(manifest);
                 }
 
                 if (aOnSuccess) {
                   aOnSuccess(id, manifest);
                 }
               } catch (e) {
                 // Something bad happened when reading the package.
-                // unrecoverable error, don't bug the user
-                app.downloadAvailable = false;
+                // Unrecoverable error, don't bug the user.
+                // Apps with installState 'pending' does not produce any
+                // notification, so we are safe with its current
+                // downladAvailable state.
+                if (app.installState === "installed") {
+                  app.downloadAvailable = false;
+                }
                 if (typeof e == 'object') {
                   Cu.reportError("Error while reading package:" + e);
                   cleanup("INVALID_PACKAGE");
                 } else {
                   cleanup(e);
                 }
               } finally {
                 AppDownloadManager.remove(aApp.manifestURL);