Bug 833587 - Updating a packaged app to a new version that is too large to fit in the phone fails, but the original packaged app is lost (no longer launches) r=ferjm a=tef+
authorFabrice Desré <fabrice@mozilla.com>
Thu, 24 Jan 2013 21:11:24 -0800
changeset 118330 8ab7e45fc123
parent 118329 96ee8f2afd10
child 118331 63f6c3b4930a
push id355
push userfdesre@mozilla.com
push dateFri, 25 Jan 2013 05:11:32 +0000
reviewersferjm, tef
bugs833587
milestone18.0
Bug 833587 - Updating a packaged app to a new version that is too large to fit in the phone fails, but the original packaged app is lost (no longer launches) r=ferjm a=tef+
dom/apps/src/Webapps.jsm
--- a/dom/apps/src/Webapps.jsm
+++ b/dom/apps/src/Webapps.jsm
@@ -1976,20 +1976,28 @@ this.DOMApplicationRegistry = {
 
       let download = AppDownloadManager.get(aApp.manifestURL);
       app.downloading = false;
 
       // To prevent repeated prompts, wait for the next checkForUpdates to
       // try a new download.
       app.downloadAvailable = false;
 
-      // If there were not enough storage to download the packaged app we
+      // If there were not enough storage to download the package we
       // won't have a record of the download details, so we just set the
-      // installState to 'pending'.
-      app.installState = download ? download.previousState : "pending";
+      // installState to 'pending' at first download and to 'installed' when
+      // updating.
+      app.installState = download ? download.previousState
+                                  : aIsUpdate ? "installed"
+                                  : "pending";
+
+      if (app.staged) {
+        delete app.staged;
+      }
+
       self.broadcastMessage("Webapps:PackageEvent",
                             { type: "error",
                               manifestURL:  aApp.manifestURL,
                               error: aError,
                               app: app });
       self._saveApps();
       AppDownloadManager.remove(aApp.manifestURL);
     }