Bug 718910 - Disable Spotlight on the cache directory on Mac; r=michal.novotny, f=smichaud,josh

This commit is contained in:
Cameron Kaiser 2012-10-02 23:05:40 -04:00
parent 349708da74
commit db848ebf08

View File

@ -40,6 +40,12 @@
#include "mozilla/net/NeckoCommon.h"
#ifdef XP_MACOSX
// for chflags()
#include <sys/stat.h>
#include <unistd.h>
#endif
using namespace mozilla;
/******************************************************************************
@ -725,6 +731,16 @@ nsCacheProfilePrefObserver::ReadPrefs(nsIPrefBranch* branch)
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);