Bug 1183689 - Having moz-safe-about+home in storage/permanent and storage/persistent breaks temporary storage initialization. r=khuey, a=ritu
authorJan Varga <jan.varga@gmail.com>
Sat, 25 Jul 2015 09:20:19 +0200
changeset 269080 2d134bf02ae474fba5569cb97db1d2ac6bbe2dca
parent 269079 14bb39fd1872ba7a80a4be1ffe117967235fee14
child 269081 0682b74572f8093de3951a9a20f1a6e0b9715ef9
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-esr52@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey, ritu
bugs1183689
milestone41.0a2
Bug 1183689 - Having moz-safe-about+home in storage/permanent and storage/persistent breaks temporary storage initialization. r=khuey, a=ritu
dom/quota/QuotaManager.cpp
--- a/dom/quota/QuotaManager.cpp
+++ b/dom/quota/QuotaManager.cpp
@@ -4737,17 +4737,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,