Bug 828267 - Installing a packaged app, lose connection during download, remove it, install it again - network error doesn't fire and app infinitely spins trying to download resources r=jst
authorFabrice Desré <fabrice@mozilla.com>
Wed, 09 Jan 2013 07:51:28 -0800
changeset 118240 4eb969119718c1a9a5449e45df7c551558260eb9
parent 118239 874e845b13c2efda6c6912e768a03ab0f9ae01ca
child 118241 a0ce5a1186669f1830768836dbd175fa439e467f
push id20940
push userfdesre@mozilla.com
push dateWed, 09 Jan 2013 15:51:37 +0000
treeherdermozilla-inbound@4eb969119718 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst
bugs828267
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 828267 - Installing a packaged app, lose connection during download, remove it, install it again - network error doesn't fire and app infinitely spins trying to download resources r=jst
dom/apps/src/Webapps.jsm
--- a/dom/apps/src/Webapps.jsm
+++ b/dom/apps/src/Webapps.jsm
@@ -1894,16 +1894,21 @@ this.DOMApplicationRegistry = {
             AppDownloadManager.remove(aApp.manifestURL);
           }
         },
         onStopRequest: function(aRequest, aContext, aStatusCode) {
           debug("onStopRequest " + aStatusCode);
           bufferedOutputStream.close();
           outputStream.close();
 
+          if (!Components.isSuccessCode(aStatusCode)) {
+            cleanup("NETWORK_ERROR");
+            return;
+          }
+
           if (requestChannel.responseStatus == 304) {
             // The package's Etag has not changed.
             // We send a "applied" event right away.
             app.downloading = false;
             app.downloadAvailable = false;
             app.downloadSize = 0;
             app.installState = "installed";
             app.readyToApplyDownload = false;
@@ -1915,21 +1920,16 @@ this.DOMApplicationRegistry = {
             self._saveApps();
             let file = FileUtils.getFile("TmpD", ["webapps", id], false);
             if (file && file.exists()) {
               file.remove(true);
             }
             return;
           }
 
-          if (!Components.isSuccessCode(aStatusCode)) {
-            cleanup("NETWORK_ERROR");
-            return;
-          }
-
           let certdb;
           try {
             certdb = Cc["@mozilla.org/security/x509certdb;1"]
                        .getService(Ci.nsIX509CertDB);
           } catch (e) {
             cleanup("CERTDB_ERROR");
             return;
           }