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, a=fabrice
authorFabrice Desré <fabrice@mozilla.com>
Wed, 09 Jan 2013 07:51:28 -0800
changeset 118074 c0b05b8ea81c1d79dd4c8a4aaad29c90bee75747
parent 118073 d709345fcceeb16811cf504726a8194be2cb4999
child 118075 c5cd0da334fd31ebc1f49b63600f371d5338b2de
push id190
push userryanvm@gmail.com
push dateWed, 09 Jan 2013 23:12:29 +0000
reviewersjst, fabrice
bugs828267
milestone18.0
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, a=fabrice
dom/apps/src/Webapps.jsm
--- a/dom/apps/src/Webapps.jsm
+++ b/dom/apps/src/Webapps.jsm
@@ -1880,16 +1880,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;
@@ -1901,21 +1906,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;
           }