Bug 801883 - New profile directories are hidden in Finder. r=josh
authorSteven Michaud <smichaud@pobox.com>
Fri, 26 Oct 2012 12:21:12 -0500
changeset 111529 b9a482aa8e57225e2a6297235048bf42c2347cd0
parent 111528 9a1be51f0a56ccc9ca4509c58f6b74c900bb7003
child 111530 e5ac0909f0578dafea58669b8f946491c7a56a25
push id17112
push usersmichaud@pobox.com
push dateFri, 26 Oct 2012 17:21:38 +0000
treeherdermozilla-inbound@b9a482aa8e57 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjosh
bugs801883
milestone19.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 801883 - New profile directories are hidden in Finder. r=josh
netwerk/cache/nsCacheService.cpp
toolkit/xre/nsXREDirProvider.cpp
--- a/netwerk/cache/nsCacheService.cpp
+++ b/netwerk/cache/nsCacheService.cpp
@@ -35,22 +35,16 @@
 #include "nsNetCID.h"
 #include <math.h>  // for log()
 #include "mozilla/Services.h"
 #include "nsITimer.h"
 
 
 #include "mozilla/net/NeckoCommon.h"
 
-#ifdef XP_MACOSX
-// for chflags()
-#include <sys/stat.h>
-#include <unistd.h>
-#endif
-
 using namespace mozilla;
 
 /******************************************************************************
  * nsCacheProfilePrefObserver
  *****************************************************************************/
 #define DISK_CACHE_ENABLE_PREF      "browser.cache.disk.enable"
 #define DISK_CACHE_DIR_PREF         "browser.cache.disk.parent_directory"
 #define DISK_CACHE_SMART_SIZE_FIRST_RUN_PREF\
@@ -727,26 +721,16 @@ nsCacheProfilePrefObserver::ReadPrefs(ns
         if (!directory && PR_GetEnv("NECKO_DEV_ENABLE_DISK_CACHE")) {
             rv = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR,
                                         getter_AddRefs(directory));
         }
         if (directory)
             mDiskCacheParentDirectory = do_QueryInterface(directory, &rv);
     }
     if (mDiskCacheParentDirectory) {
-#ifdef XP_MACOSX
-        // ensure that this directory is not indexed by Spotlight
-        // (bug 718910). it may already exist, so we "just do it."
-        nsAutoCString cachePD;
-        if (NS_SUCCEEDED(mDiskCacheParentDirectory->GetNativePath(cachePD))) {
-            if (chflags(cachePD.get(), UF_HIDDEN)) {
-                NS_WARNING("Failed to set CacheParentDirectory to HIDDEN.");
-            }
-        }
-#endif 
         bool firstSmartSizeRun;
         rv = branch->GetBoolPref(DISK_CACHE_SMART_SIZE_FIRST_RUN_PREF, 
                                  &firstSmartSizeRun); 
         if (NS_FAILED(rv)) 
             firstSmartSizeRun = false;
         if (PermittedToSmartSize(branch, firstSmartSizeRun)) {
             // Avoid evictions: use previous cache size until smart size event
             // updates mDiskCacheCapacity
--- a/toolkit/xre/nsXREDirProvider.cpp
+++ b/toolkit/xre/nsXREDirProvider.cpp
@@ -39,16 +39,19 @@
 #include <stdlib.h>
 
 #ifdef XP_WIN
 #include <windows.h>
 #include <shlobj.h>
 #endif
 #ifdef XP_MACOSX
 #include "nsILocalFileMac.h"
+// for chflags()
+#include <sys/stat.h>
+#include <unistd.h>
 #endif
 #ifdef XP_UNIX
 #include <ctype.h>
 #endif
 #ifdef XP_OS2
 #define INCL_DOS
 #include <os2.h>
 #endif
@@ -127,16 +130,40 @@ nsXREDirProvider::SetProfile(nsIFile* aD
   rv = EnsureDirectoryExists(aDir);
   if (NS_FAILED(rv))
     return rv;
 
   rv = EnsureDirectoryExists(aLocalDir);
   if (NS_FAILED(rv))
     return rv;
 
+#ifdef XP_MACOSX
+  bool same;
+  if (NS_SUCCEEDED(aDir->Equals(aLocalDir, &same)) && !same) {
+    // Ensure that the cache directory is not indexed by Spotlight
+    // (bug 718910).  At least on OS X, the cache directory (under
+    // ~/Library/Caches/) is always the "local" user profile
+    // directory.  This is confusing, since *both* user profile
+    // directories are "local" (they both exist under the user's
+    // home directory).  But this usage dates back at least as far
+    // as the patch for bug 291033, where "local" seems to mean
+    // "suitable for temporary storage".  Don't hide the cache
+    // directory if by some chance it and the "non-local" profile
+    // directory are the same -- there are bad side effects from
+    // hiding a profile directory under /Library/Application Support/
+    // (see bug 801883).
+    nsAutoCString cacheDir;
+    if (NS_SUCCEEDED(aLocalDir->GetNativePath(cacheDir))) {
+      if (chflags(cacheDir.get(), UF_HIDDEN)) {
+        NS_WARNING("Failed to set Cache directory to HIDDEN.");
+      }
+    }
+  }
+#endif
+
   mProfileDir = aDir;
   mProfileLocalDir = aLocalDir;
   return NS_OK;
 }
 
 NS_IMPL_QUERY_INTERFACE3(nsXREDirProvider,
                          nsIDirectoryServiceProvider,
                          nsIDirectoryServiceProvider2,