Bug 1183689 - Having moz-safe-about+home in storage/permanent and storage/persistent breaks temporary storage initialization; r=khuey
authorJan Varga <jan.varga@gmail.com>
Sat, 25 Jul 2015 09:20:19 +0200
changeset 254598 a983b06b1be393b73b6aef5cb2a2b6729145633e
parent 254597 4d96b3d42fd9663eacd36c1ef39c55e6ee7af452
child 254599 59f70ba8d1ab732b945ba2c7db8489103d62bc9d
push id29108
push userryanvm@gmail.com
push dateMon, 27 Jul 2015 14:12:01 +0000
treeherdermozilla-central@27ae736ef960 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1183689
milestone42.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 1183689 - Having moz-safe-about+home in storage/permanent and storage/persistent breaks temporary storage initialization; r=khuey
dom/quota/QuotaManager.cpp
--- a/dom/quota/QuotaManager.cpp
+++ b/dom/quota/QuotaManager.cpp
@@ -5235,17 +5235,47 @@ StorageDirectoryHelper::ProcessOriginDir
             quotaManager->GetStoragePath(PERSISTENCE_TYPE_PERSISTENT);
 
           rv = permanentStorageDir->InitWithPath(permanentStoragePath);
           if (NS_WARN_IF(NS_FAILED(rv))) {
             return rv;
           }
         }
 
-        rv = originProps.mDirectory->MoveTo(permanentStorageDir, EmptyString());
+        nsString leafName;
+        rv = originProps.mDirectory->GetLeafName(leafName);
+        if (NS_WARN_IF(NS_FAILED(rv))) {
+          return rv;
+        }
+
+        nsCOMPtr<nsIFile> newDirectory;
+        rv = permanentStorageDir->Clone(getter_AddRefs(newDirectory));
+        if (NS_WARN_IF(NS_FAILED(rv))) {
+          return rv;
+        }
+
+        rv = newDirectory->Append(leafName);
+        if (NS_WARN_IF(NS_FAILED(rv))) {
+          return rv;
+        }
+
+        bool exists;
+        rv = newDirectory->Exists(&exists);
+        if (NS_WARN_IF(NS_FAILED(rv))) {
+          return rv;
+        }
+
+        if (exists) {
+          QM_WARNING("Found %s in storage/persistent and storage/permanent !",
+                     NS_ConvertUTF16toUTF8(leafName).get());
+
+          rv = originProps.mDirectory->Remove(/* recursive */ true);
+        } else {
+          rv = originProps.mDirectory->MoveTo(permanentStorageDir, EmptyString());
+        }
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
       }
     } else {
       nsCOMPtr<nsIBinaryOutputStream> stream;
       rv = GetDirectoryMetadataOutputStream(originProps.mDirectory,
                                             kAppendFileFlag,