Add in some cache stats for the about box

master
Callum Prentice 2020-10-07 16:03:28 -07:00
parent 08dfc0836f
commit 5fdc4a1fb4
4 changed files with 28 additions and 20 deletions

View File

@ -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();
}
@ -203,6 +201,24 @@ void LLDiskCache::updateFileAccessTime(const std::string file_path)
boost::filesystem::last_write_time(file_path, file_time);
}
/**
*
*/
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

View File

@ -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

View File

@ -3196,6 +3196,9 @@ LLSD LLAppViewer::getViewerInfo() const
info["SERVER_RELEASE_NOTES_URL"] = mServerReleaseNotesURL;
}
// populate field for new local disk cache with some details
info["DISK_CACHE_INFO"] = LLDiskCache::getInstance()->getCacheInfo();
return info;
}

View File

@ -55,8 +55,9 @@ LOD factor: [LOD_FACTOR]
Render quality: [RENDER_QUALITY]
Advanced Lighting Model: [GPU_SHADERS]
Texture memory: [TEXTURE_MEMORY]MB
Disk cache: [DISK_CACHE_INFO]
</string>
<string name="AboutOSXHiDPI">
<string name="AboutOSXHiDPI">
HiDPI display mode: [HIDPI]
</string>
<string name="AboutLibs">