diff options
author | Callum Prentice <callum@gmail.com> | 2020-10-07 16:03:28 -0700 |
---|---|---|
committer | Callum Prentice <callum@gmail.com> | 2020-10-07 16:03:28 -0700 |
commit | 5fdc4a1fb4a1788b20ca7a2e7764fd1391c35785 (patch) | |
tree | 00c85045c03ae4beb4d4c0ea62e5b39286bdef98 /indra/llfilesystem | |
parent | 08dfc0836fb12855d0c07d811e2909400d5b74f3 (diff) |
Add in some cache stats for the about box
Diffstat (limited to 'indra/llfilesystem')
-rw-r--r-- | indra/llfilesystem/lldiskcache.cpp | 20 | ||||
-rw-r--r-- | indra/llfilesystem/lldiskcache.h | 22 |
2 files changed, 23 insertions, 19 deletions
diff --git a/indra/llfilesystem/lldiskcache.cpp b/indra/llfilesystem/lldiskcache.cpp index 4b82cf3cce..455e27221e 100644 --- a/indra/llfilesystem/lldiskcache.cpp +++ b/indra/llfilesystem/lldiskcache.cpp @@ -187,8 +187,6 @@ const std::string LLDiskCache::metaDataToFilepath(const std::string id, file_path << assetTypeToString(at); file_path << ".asset"; - LL_INFOS() << "filepath.str() = " << file_path.str() << LL_ENDL; - return file_path.str(); } @@ -204,6 +202,24 @@ void LLDiskCache::updateFileAccessTime(const std::string file_path) } /** + * + */ +const std::string LLDiskCache::getCacheInfo() +{ + std::ostringstream cache_info; + + F32 max_in_mb = (F32)mMaxSizeBytes / (1024.0 * 1024.0); + F32 percent_used = ((F32)dirFileSize(mCacheDir) / (F32)mMaxSizeBytes) * 100.0; + + cache_info << std::fixed; + cache_info << std::setprecision(1); + cache_info << "Max size " << max_in_mb << " MB "; + cache_info << "(" << percent_used << "% used)"; + + return cache_info.str(); +} + +/** * Clear the cache by removing all the files in the cache directory * individually. It's important to maintain control of which directory * if passed in and not let the user inadvertently (or maliciously) set diff --git a/indra/llfilesystem/lldiskcache.h b/indra/llfilesystem/lldiskcache.h index 12599a132e..34a4fda756 100644 --- a/indra/llfilesystem/lldiskcache.h +++ b/indra/llfilesystem/lldiskcache.h @@ -40,23 +40,6 @@ class LLDiskCache : virtual ~LLDiskCache() = default; public: - ///** - // * The location of the cache dir is set in llappviewer at startup via the - // * saved settings parameters. We do not have access to those saved settings - // * here in LLCommon so we must provide an accessor for other classes to use - // * when they need it - e.g. LLFilesystem needs the path so it can write files - // * to it. - // */ - //const std::string getCacheDirName() { return mCacheDir; } - - ///** - // * Each cache filename has a prefix inserted (see definition of the - // * mCacheFilenamePrefix variable below for why) but the LLFileSystem - // * component needs access to it to in order to create the file so we - // * expose it by a getter here. - // */ - //const std::string getCacheFilenamePrefix() { return mCacheFilenamePrefix; } - /** * Construct a filename and path to it based on the file meta data * (id, asset type, additional 'extra' info like discard level perhaps) @@ -86,6 +69,11 @@ class LLDiskCache : */ void clearCache(const std::string cache_dir); + /** + * Return some information about the cache for use in About Box etc. + */ + const std::string getCacheInfo(); + private: /** * Utility function to gather the total size the files in a given |