summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Nikolenko <maximnproductengine@lindenlab.com>2020-10-08 16:16:38 +0000
committerCallum Linden <callum@lindenlab.com>2020-10-08 16:16:38 +0000
commit9f6a60cd85b8c5fdc41e741aabc91439508b877a (patch)
tree763df757d2660cf5f124de8f1164136ab2203963
parenta818c44ef21cf6b4e4eeab0ee0325a780898fccc (diff)
parent3051db7b61ee43fffd28f0a12c0714b11b6b7df7 (diff)
Merged in maxim_productengine/maxim-viewer/DRTVWR-519 (pull request #332)
Purge excessive files from disc cache each startup Approved-by: Callum Linden <callum@lindenlab.com>
-rw-r--r--indra/llfilesystem/lldiskcache.cpp6
-rw-r--r--indra/llfilesystem/lldiskcache.h2
-rw-r--r--indra/newview/llappviewer.cpp32
3 files changed, 24 insertions, 16 deletions
diff --git a/indra/llfilesystem/lldiskcache.cpp b/indra/llfilesystem/lldiskcache.cpp
index e2e50c775d..efe5e7092c 100644
--- a/indra/llfilesystem/lldiskcache.cpp
+++ b/indra/llfilesystem/lldiskcache.cpp
@@ -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))
{
diff --git a/indra/llfilesystem/lldiskcache.h b/indra/llfilesystem/lldiskcache.h
index f718b7a328..b25eac8538 100644
--- a/indra/llfilesystem/lldiskcache.h
+++ b/indra/llfilesystem/lldiskcache.h
@@ -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.
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index afafedf207..9e50860064 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -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;
}