Bug 961468 - In _readManifests, read the manifests without checking file existence. r=fabrice
authorMarco Castelluccio <mar.castelluccio@studenti.unina.it>
Fri, 31 Jan 2014 13:14:17 -0500
changeset 166292 a2c030eb1c50e142fd1f3dcc664a19ef2607c4c3
parent 166291 ec4d78ce039fe8e33ead58ef5e53ce3309b3e1f1
child 166293 111d77c40e201dffbe483f35e569ac2f5cdec62d
push id4324
push userryanvm@gmail.com
push dateFri, 31 Jan 2014 18:14:21 +0000
treeherderb2g-inbound@111d77c40e20 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice
bugs961468
milestone29.0a1
Bug 961468 - In _readManifests, read the manifests without checking file existence. r=fabrice
dom/apps/src/Webapps.jsm
--- a/dom/apps/src/Webapps.jsm
+++ b/dom/apps/src/Webapps.jsm
@@ -2582,39 +2582,33 @@ onInstallSuccessAck: function onInstallS
   /**
     * Asynchronously reads a list of manifests
     */
 
   _manifestCache: {},
 
   _readManifests: function(aData) {
     return Task.spawn(function*() {
-      if (!aData.length) {
-        return aData;
-      }
-
       for (let elem of aData) {
         let id = elem.id;
 
         if (!this._manifestCache[id]) {
           // the manifest file used to be named manifest.json, so fallback on this.
           let baseDir = this.webapps[id].basePath == this.getCoreAppsBasePath()
                           ? "coreAppsDir" : DIRECTORY_NAME;
 
-          let file = FileUtils.getFile(baseDir, ["webapps", id, "manifest.webapp"], true);
-
-          if (!file.exists()) {
-            file = FileUtils.getFile(baseDir, ["webapps", id, "update.webapp"], true);
+          let dir = FileUtils.getDir(baseDir, ["webapps", id], false, true);
+
+          let fileNames = ["manifest.webapp", "update.webapp", "manifest.json"];
+          for (let fileName of fileNames) {
+            this._manifestCache[id] = yield this._loadJSONAsync(OS.Path.join(dir.path, fileName));
+            if (this._manifestCache[id]) {
+              break;
+            }
           }
-
-          if (!file.exists()) {
-            file = FileUtils.getFile(baseDir, ["webapps", id, "manifest.json"], true);
-          }
-
-          this._manifestCache[id] = yield this._loadJSONAsync(file.path);
         }
 
         elem.manifest = this._manifestCache[id];
       }
 
       return aData;
     }.bind(this)).then(null, Cu.reportError);
   },