Bug 411353 ? Default bookmarks and Smart folder missing from New Profile (r=bsmedberg, a=revert)
authordietrich@mozilla.com
Tue, 08 Jan 2008 18:23:31 -0800
changeset 10037 4733ccebec84c05ad68ded60dabebd47da46d0b2
parent 10036 5701f888686628e488855235c884182f0f14c24b
child 10038 5ccfe0f4324b7e2e2e468158b5c13039bcf4cf3f
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherdermozilla-central@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, revert
bugs411353
milestone1.9b3pre
Bug 411353 ? Default bookmarks and Smart folder missing from New Profile (r=bsmedberg, a=revert)
toolkit/profile/src/nsToolkitProfileService.cpp
--- a/toolkit/profile/src/nsToolkitProfileService.cpp
+++ b/toolkit/profile/src/nsToolkitProfileService.cpp
@@ -681,17 +681,40 @@ nsToolkitProfileService::CreateProfile(n
     if (exists) {
         rv = rootDir->IsDirectory(&exists);
         NS_ENSURE_SUCCESS(rv, rv);
 
         if (!exists)
             return NS_ERROR_FILE_NOT_DIRECTORY;
     }
     else {
-        rv = rootDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
+        nsCOMPtr<nsIFile> profileDefaultsDir;
+        nsCOMPtr<nsIFile> profileDirParent;
+        nsCAutoString profileDirName;
+
+        rv = rootDir->GetParent(getter_AddRefs(profileDirParent));
+        NS_ENSURE_SUCCESS(rv, rv);
+
+        rv = rootDir->GetNativeLeafName(profileDirName);
+        NS_ENSURE_SUCCESS(rv, rv);
+
+        PRBool dummy;
+        rv = gDirServiceProvider->GetFile(NS_APP_PROFILE_DEFAULTS_50_DIR, &dummy,
+                                          getter_AddRefs(profileDefaultsDir));
+
+        if (NS_SUCCEEDED(rv))
+            rv = profileDefaultsDir->CopyToNative(profileDirParent,
+                                                  profileDirName);
+        if (NS_FAILED(rv)) {
+            // if copying failed, lets just ensure that the profile directory exists.
+            rv = rootDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
+            NS_ENSURE_SUCCESS(rv, rv);
+        }
+      
+        rv = rootDir->SetPermissions(0700);
         NS_ENSURE_SUCCESS(rv, rv);
     }
 
     rv = localDir->Exists(&exists);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (!exists) {
         rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0700);