Bug 805967 - [OTA update] much of my user data blown away in today's update [r=sicking]
authorFabrice Desré <fabrice@mozilla.com>
Tue, 30 Oct 2012 00:11:17 -0700
changeset 111971 58ddfb88815a8008cf2e62eb55eb4d9c8fc3b6af
parent 111970 0ab79ed8030221e43a65f342833faf4b31616ec8
child 111972 078e5c209552a2e7494c8596464cc055939c4eef
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewerssicking
bugs805967
milestone19.0a1
Bug 805967 - [OTA update] much of my user data blown away in today's update [r=sicking]
dom/apps/src/Webapps.jsm
--- a/dom/apps/src/Webapps.jsm
+++ b/dom/apps/src/Webapps.jsm
@@ -241,19 +241,53 @@ this.DOMApplicationRegistry = {
         }
         aNext();
       }).bind(this));
     } else {
       aNext();
     }
   },
 
+#ifdef MOZ_WIDGET_GONK
+  fixIndexedDb: function fixIndexedDb() {
+    debug("Fixing indexedDb folder names");
+    let idbDir = FileUtils.getDir("indexedDBPDir", ["indexedDB"]);
+
+    if (!idbDir.isDirectory()) {
+      return;
+    }
+
+    let re = /^(\d+)\+(.*)\+(f|t)$/;
+
+    let entries = idbDir.directoryEntries;
+    while (entries.hasMoreElements()) {
+      let entry = entries.getNext().QueryInterface(Ci.nsIFile);
+      if (!entry.isDirectory()) {
+        continue;
+      }
+
+      let newName = entry.leafName.replace(re, "$1+$3+$2");
+      if (newName != entry.leafName) {
+        try {
+          entry.moveTo(idbDir, newName);
+        } catch(e) { }
+      }
+    }
+  },
+#endif
+
   loadAndUpdateApps: function loadAndUpdateApps() {
     let runUpdate = AppsUtils.isFirstRun(Services.prefs);
 
+#ifdef MOZ_WIDGET_GONK
+    if (runUpdate) {
+      this.fixIndexedDb();
+    }
+#endif
+
     let onAppsLoaded = (function onAppsLoaded() {
       if (runUpdate) {
         // At first run, set up the permissions
         for (let id in this.webapps) {
           this.updatePermissionsForApp(id);
           this.updateOfflineCacheForApp(id);
         }
       }