Purge excessive files from disc cache each startup
parent
a818c44ef2
commit
3051db7b61
|
|
@ -215,7 +215,7 @@ const std::string LLDiskCache::getCacheInfo()
|
|||
return cache_info.str();
|
||||
}
|
||||
|
||||
void LLDiskCache::clearCache(const std::string cache_dir)
|
||||
void LLDiskCache::clearCache()
|
||||
{
|
||||
/**
|
||||
* See notes on performance in dirFileSize(..) - there may be
|
||||
|
|
@ -223,9 +223,9 @@ void LLDiskCache::clearCache(const std::string cache_dir)
|
|||
* the component files but it's called infrequently so it's
|
||||
* likely just fine
|
||||
*/
|
||||
if (boost::filesystem::is_directory(cache_dir))
|
||||
if (boost::filesystem::is_directory(mCacheDir))
|
||||
{
|
||||
for (auto& entry : boost::make_iterator_range(boost::filesystem::directory_iterator(cache_dir), {}))
|
||||
for (auto& entry : boost::make_iterator_range(boost::filesystem::directory_iterator(mCacheDir), {}))
|
||||
{
|
||||
if (boost::filesystem::is_regular_file(entry))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ class LLDiskCache :
|
|||
* directory individually. Only the files that contain a prefix defined
|
||||
* by mCacheFilenamePrefix will be removed.
|
||||
*/
|
||||
void clearCache(const std::string cache_dir);
|
||||
void clearCache();
|
||||
|
||||
/**
|
||||
* Return some information about the cache for use in About Box etc.
|
||||
|
|
|
|||
|
|
@ -4061,6 +4061,13 @@ bool LLAppViewer::initCache()
|
|||
LLAppViewer::getTextureCache()->setReadOnly(read_only) ;
|
||||
LLVOCache::initParamSingleton(read_only);
|
||||
|
||||
// initialize the new disk cache using saved settings
|
||||
const std::string cache_dir_name = gSavedSettings.getString("DiskCacheDirName");
|
||||
const unsigned int cache_max_bytes = gSavedSettings.getU32("DiskCacheMaxSizeMB") * 1024 * 1024;
|
||||
const bool enable_cache_debug_info = gSavedSettings.getBOOL("EnableDiskCacheDebugInfo");
|
||||
const std::string cache_dir = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, cache_dir_name);
|
||||
LLDiskCache::initParamSingleton(cache_dir, cache_max_bytes, enable_cache_debug_info);
|
||||
|
||||
bool texture_cache_mismatch = false;
|
||||
if (gSavedSettings.getS32("LocalCacheVersion") != LLAppViewer::getTextureCacheVersion())
|
||||
{
|
||||
|
|
@ -4107,13 +4114,21 @@ bool LLAppViewer::initCache()
|
|||
gSavedSettings.setString("CacheLocationTopFolder", "");
|
||||
}
|
||||
|
||||
if (mPurgeCache && !read_only)
|
||||
if (!read_only)
|
||||
{
|
||||
LLSplashScreen::update(LLTrans::getString("StartupClearingCache"));
|
||||
purgeCache();
|
||||
if (mPurgeCache)
|
||||
{
|
||||
LLSplashScreen::update(LLTrans::getString("StartupClearingCache"));
|
||||
purgeCache();
|
||||
|
||||
// purge the new C++ file system based cache
|
||||
LLDiskCache::getInstance()->purge();
|
||||
// clear the new C++ file system based cache
|
||||
LLDiskCache::getInstance()->clearCache();
|
||||
}
|
||||
else
|
||||
{
|
||||
// purge excessive files from the new file system based cache
|
||||
LLDiskCache::getInstance()->purge();
|
||||
}
|
||||
}
|
||||
|
||||
LLSplashScreen::update(LLTrans::getString("StartupInitializingTextureCache"));
|
||||
|
|
@ -4134,13 +4149,6 @@ bool LLAppViewer::initCache()
|
|||
|
||||
LLVOCache::getInstance()->initCache(LL_PATH_CACHE, gSavedSettings.getU32("CacheNumberOfRegionsForObjects"), getObjectCacheVersion());
|
||||
|
||||
// initialize the new disk cache using saved settings
|
||||
const std::string cache_dir_name = gSavedSettings.getString("DiskCacheDirName");
|
||||
const unsigned int cache_max_bytes = gSavedSettings.getU32("DiskCacheMaxSizeMB") * 1024 * 1024;
|
||||
const bool enable_cache_debug_info = gSavedSettings.getBOOL("EnableDiskCacheDebugInfo");
|
||||
const std::string cache_dir = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, cache_dir_name);
|
||||
LLDiskCache::initParamSingleton(cache_dir, cache_max_bytes, enable_cache_debug_info);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue