Bug 1195930 - Part 9: Remove old directories (fixes bug 1273717); r=asuth
authorJan Varga <jan.varga@gmail.com>
Sun, 05 Jun 2016 21:42:55 +0200
changeset 339568 9b32c8b9be79ebec078a1ff5bdad089b342dc58e
parent 339567 804d10cab665b2ce1ac20807d91c4207b17037b9
child 339569 06132a28bab61ed293aaf0f5255e5408ee493d09
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1195930, 1273717
milestone49.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 1195930 - Part 9: Remove old directories (fixes bug 1273717); r=asuth
dom/indexedDB/test/unit/oldDirectories_profile.zip
dom/indexedDB/test/unit/test_oldDirectories.js
dom/indexedDB/test/unit/xpcshell-parent-process.ini
dom/quota/ActorsParent.cpp
dom/quota/QuotaManager.h
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..09209d351a6a3f6b3836fac1fb593b53a8b69bdd
GIT binary patch
literal 9241
zc$}@72{@Ep8^@<)DIyVxOe;c`7~3%3wA%*RvQ2ifo3V|Ur1F;Jl`VTEB>R%J8B3|`
zN%okKotcEmSY|%bS7e*s?|WR&b<McW{C{)q=bX9!=f2gHsJ5{J0025bj&aF(WGG+Q
z%`E@`VJiT@2;c&kI-46K%wc9GLRJVnTP@A)0IK(<DmqmQw~ISHV9U0tg~8uHA9EjS
z(<`#80#9PifgC-O6^Rx+qWTaum^G<J$R0hJ_d4%R8uNQ8YrUCHflJ2uYJ9o0#^Ok*
ze0^hxymku1r}xnhc|4tq#`fmY-c)S4ufB!F(a%v{8=c;LizZoxS#W<&C!IPtB$Y|G
zQRJU->O$?-3n@Iw?q|=L7#jR-`@G%K{LLw#JYN&!qegZ=_cx|Nj<X#y$-DNQqx#rY
zU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ZX-VGLS}AZ}_~+QJeRI)Y@R=y2&l6dj*{B-Giw9GmguP6~^)2GPyDg5R&2yrX
z-rKiS<yEqki0fvIG>_kQs<3h!3iEJQcl^Xg)DF3ylVid=6yk?1ode+n{3nL^LC*|*
z11-w15w6@_88bV7{A$@BA?15?ccIYqKmOq!m)NTGVz#&x^Wz_%Xow0kgBK350W)xE
zC3#~ng~P)G@7)W#62Q`!J(+NJ;;#n=7X&f$aJ}iBC^GHRho*t06Y@(hOUK@j$?~z}
zAF0`1QkG1$^zx&(JL$*xg846VKYWzqY&Q|OGB<wepXF3j+On0KYQ2WrlBZfkT=Q9c
z^?Un`da3=k>X&s<bG^RLe|_36z}U&!g^w)n0#Pq@fi}=v-2+;#$GjClNk@o!sUx%j
zW_3U4m%V)AV@nBUSr(>V>JDwdTiqL4KCO3@@Rm|6^-?Egqp7Xx6D>yxQ&EWey=z3h
zR7O}6yk5^}c}%1K75Hbm-F)7w>u$^E-Lf#~R~3$WsS3A&+UgqIay1Tmz}gi#>ZOX@
z2EwcBam$4*))wAqrLS2mTc0Pk;;B^q5pU&^-vqq6PPcrbk_>+W{<-#*HfFA_*)3<r
z{V{Vz1#j~mu)2P?Jl4B+{(JoLeX#DASnmw<D+Z+}FR}vGI1y1VorpG2U40%}t{St3
z>PBmJO}qXpj;qf`zv6h!heSDS<$_(8y58|;`4ofpP)z-~TK^Czy#h%1GvMzBBg&$@
j@>sMy%GPZE9>09GuK6XXzi$xMg})Fw0KkEB@!fv_%9tFL
new file mode 100644
--- /dev/null
+++ b/dom/indexedDB/test/unit/test_oldDirectories.js
@@ -0,0 +1,72 @@
+/**
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+var testGenerator = testSteps();
+
+function testSteps()
+{
+  // This lives in storage/default/http+++www.mozilla.org
+  const url = "http://www.mozilla.org";
+  const dbName = "dbC";
+  const dbVersion = 1;
+
+  let ios = SpecialPowers.Cc["@mozilla.org/network/io-service;1"]
+                         .getService(SpecialPowers.Ci.nsIIOService);
+
+  let ssm = SpecialPowers.Cc["@mozilla.org/scriptsecuritymanager;1"]
+                         .getService(SpecialPowers.Ci.nsIScriptSecurityManager);
+
+  function openDatabase() {
+    let uri = ios.newURI(url, null, null);
+    let principal = ssm.createCodebasePrincipal(uri, {});
+    let request = indexedDB.openForPrincipal(principal, dbName, dbVersion);
+    return request;
+  }
+
+  clearAllDatabases(continueToNextStepSync);
+  yield undefined;
+
+  installPackagedProfile("oldDirectories_profile");
+
+  let request = openDatabase();
+  request.onerror = errorHandler;
+  request.onupgradeneeded = unexpectedSuccessHandler;
+  request.onsuccess = grabEventAndContinueHandler;
+  let event = yield undefined;
+
+  is(event.type, "success", "Correct event type");
+
+  resetAllDatabases(continueToNextStepSync);
+  yield undefined;
+
+  request = openDatabase();
+  request.onerror = errorHandler;
+  request.onupgradeneeded = unexpectedSuccessHandler;
+  request.onsuccess = grabEventAndContinueHandler;
+  event = yield undefined;
+
+  is(event.type, "success", "Correct event type");
+
+  let directoryService = Cc["@mozilla.org/file/directory_service;1"]
+                         .getService(Ci.nsIProperties);
+
+  let profileDir = directoryService.get("ProfD", Ci.nsIFile);
+
+  let dir = profileDir.clone();
+  dir.append("indexedDB");
+
+  let exists = dir.exists();
+  ok(!exists, "indexedDB doesn't exist");
+
+  dir = profileDir.clone();
+  dir.append("storage");
+  dir.append("persistent");
+
+  exists = dir.exists();
+  ok(!exists, "storage/persistent doesn't exist");
+
+  finishTest();
+  yield undefined;
+}
--- a/dom/indexedDB/test/unit/xpcshell-parent-process.ini
+++ b/dom/indexedDB/test/unit/xpcshell-parent-process.ini
@@ -8,16 +8,17 @@ head = xpcshell-head-parent-process.js
 tail =
 skip-if = toolkit == 'gonk'
 support-files =
   bug1056939_profile.zip
   defaultStorageUpgrade_profile.zip
   idbSubdirUpgrade1_profile.zip
   idbSubdirUpgrade2_profile.zip
   mutableFileUpgrade_profile.zip
+  oldDirectories_profile.zip
   GlobalObjectsChild.js
   GlobalObjectsComponent.js
   GlobalObjectsComponent.manifest
   GlobalObjectsModule.jsm
   GlobalObjectsSandbox.js
   metadata2Restore_profile.zip
   metadataRestore_profile.zip
   schema18upgrade_profile.zip
@@ -38,16 +39,17 @@ skip-if = toolkit == 'android'
 [test_idle_maintenance.js]
 [test_invalidate.js]
 # disabled for the moment.
 skip-if = true
 [test_lowDiskSpace.js]
 [test_metadata2Restore.js]
 [test_metadataRestore.js]
 [test_mutableFileUpgrade.js]
+[test_oldDirectories.js]
 [test_quotaExceeded_recovery.js]
 [test_readwriteflush_disabled.js]
 [test_schema18upgrade.js]
 [test_schema21upgrade.js]
 [test_schema23upgrade.js]
 [test_storagePersistentUpgrade.js]
 [test_temporary_storage.js]
 # bug 951017: intermittent failure on Android x86 emulator
--- a/dom/quota/ActorsParent.cpp
+++ b/dom/quota/ActorsParent.cpp
@@ -4122,16 +4122,82 @@ QuotaManager::MaybeUpgradePersistentStor
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   return NS_OK;
 }
 
 nsresult
+QuotaManager::MaybeRemoveOldDirectories()
+{
+  AssertIsOnIOThread();
+
+  nsresult rv;
+
+  nsCOMPtr<nsIFile> indexedDBDir =
+    do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
+  }
+
+  rv = indexedDBDir->InitWithPath(mIndexedDBPath);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
+  }
+
+  bool exists;
+  rv = indexedDBDir->Exists(&exists);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
+  }
+
+  if (exists) {
+    QM_WARNING("Deleting old <profile>/indexedDB directory!");
+
+    rv = indexedDBDir->Remove(/* aRecursive */ true);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
+  }
+
+  nsCOMPtr<nsIFile> persistentStorageDir =
+    do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
+  }
+
+  rv = persistentStorageDir->InitWithPath(mStoragePath);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
+  }
+
+  rv = persistentStorageDir->Append(NS_LITERAL_STRING(PERSISTENT_DIRECTORY_NAME));
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
+  }
+
+  rv = persistentStorageDir->Exists(&exists);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
+  }
+
+  if (exists) {
+    QM_WARNING("Deleting old <profile>/storage/persistent directory!");
+
+    rv = persistentStorageDir->Remove(/* aRecursive */ true);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
+  }
+
+  return NS_OK;
+}
+
+nsresult
 QuotaManager::UpgradeStorageFrom0To1(mozIStorageConnection* aConnection)
 {
   AssertIsOnIOThread();
   MOZ_ASSERT(aConnection);
 
   nsresult rv;
 
   for (const PersistenceType persistenceType : kAllPersistenceTypes) {
@@ -4221,25 +4287,17 @@ nsresult
 QuotaManager::EnsureStorageIsInitialized()
 {
   AssertIsOnIOThread();
 
   if (mStorageInitialized) {
     return NS_OK;
   }
 
-  nsresult rv = MaybeUpgradeIndexedDBDirectory();
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
-  }
-
-  rv = MaybeUpgradePersistentStorageDirectory();
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
-  }
+  nsresult rv;
 
   nsCOMPtr<nsIFile> storageFile =
     do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = storageFile->InitWithPath(mBasePath);
@@ -4288,16 +4346,31 @@ QuotaManager::EnsureStorageIsInitialized
     NS_WARNING("Unable to initialize storage, version is too high!");
     return NS_ERROR_FAILURE;
   }
 
   if (storageVersion != kStorageVersion) {
     const bool newDatabase = !storageVersion;
 
     if (newDatabase) {
+      rv = MaybeUpgradeIndexedDBDirectory();
+      if (NS_WARN_IF(NS_FAILED(rv))) {
+        return rv;
+      }
+
+      rv = MaybeUpgradePersistentStorageDirectory();
+      if (NS_WARN_IF(NS_FAILED(rv))) {
+        return rv;
+      }
+
+      rv = MaybeRemoveOldDirectories();
+      if (NS_WARN_IF(NS_FAILED(rv))) {
+        return rv;
+      }
+
       rv = UpgradeStorageFrom0To1(connection);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     } else {
       // This logic needs to change next time we change the schema!
       static_assert(kStorageVersion == 1,
                     "Upgrade function needed due to storage version increase.");
--- a/dom/quota/QuotaManager.h
+++ b/dom/quota/QuotaManager.h
@@ -437,16 +437,19 @@ private:
 
   nsresult
   MaybeUpgradeIndexedDBDirectory();
 
   nsresult
   MaybeUpgradePersistentStorageDirectory();
 
   nsresult
+  MaybeRemoveOldDirectories();
+
+  nsresult
   UpgradeStorageFrom0To1(mozIStorageConnection* aConnection);
 
 #if 0
   nsresult
   UpgradeStorageFrom1To2(mozIStorageConnection* aConnection);
 #endif
 
   nsresult