summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2025-02-18 17:22:04 +0200
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2025-02-18 18:40:39 +0200
commit60121683eab4085e7d7b0e364c3c4c0089eebf32 (patch)
treedea0ff481de39f924f7f4cba533de0e51584072c /indra
parent5029f0322f264e17f7509952f7bf9812db17a9ec (diff)
#3520 Name name cache based on grid
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llappviewer.cpp35
1 files changed, 27 insertions, 8 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index c770b7c917..e1568c40c3 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -4464,11 +4464,32 @@ void LLAppViewer::saveFinalSnapshot()
}
}
+static const char PRODUCTION_CACHE_FORMAT_STRING[] = "%s.%s";
+static const char GRID_CACHE_FORMAT_STRING[] = "%s.%s.%s";
+std::string get_name_cache_filename(const std::string &base_file, const std::string& extention)
+{
+ std::string filename;
+ std::string path(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, base_file));
+ if (LLGridManager::getInstance()->isInProductionGrid())
+ {
+ filename = llformat(PRODUCTION_CACHE_FORMAT_STRING, path.c_str(), extention.c_str());
+ }
+ else
+ {
+ // NOTE: The inventory cache filenames now include the grid name.
+ // Add controls against directory traversal or problematic pathname lengths
+ // if your viewer uses grid names from an untrusted source.
+ const std::string& grid_id_str = LLGridManager::getInstance()->getGridId();
+ const std::string& grid_id_lower = utf8str_tolower(grid_id_str);
+ filename = llformat(GRID_CACHE_FORMAT_STRING, path.c_str(), grid_id_lower.c_str(), extention.c_str());
+ }
+ return filename;
+}
+
void LLAppViewer::loadNameCache()
{
// display names cache
- std::string filename =
- gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "avatar_name_cache.xml");
+ std::string filename = get_name_cache_filename("avatar_name_cache", "xml");
LL_INFOS("AvNameCache") << filename << LL_ENDL;
llifstream name_cache_stream(filename.c_str());
if(name_cache_stream.is_open())
@@ -4483,8 +4504,8 @@ void LLAppViewer::loadNameCache()
if (!gCacheName) return;
- std::string name_cache;
- name_cache = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "name.cache");
+ // is there a reason for the "cache" extention?
+ std::string name_cache = get_name_cache_filename("name", "cache");
llifstream cache_file(name_cache.c_str());
if(cache_file.is_open())
{
@@ -4495,8 +4516,7 @@ void LLAppViewer::loadNameCache()
void LLAppViewer::saveNameCache()
{
// display names cache
- std::string filename =
- gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "avatar_name_cache.xml");
+ std::string filename = get_name_cache_filename("avatar_name_cache", "xml");
llofstream name_cache_stream(filename.c_str());
if(name_cache_stream.is_open())
{
@@ -4506,8 +4526,7 @@ void LLAppViewer::saveNameCache()
// real names cache
if (gCacheName)
{
- std::string name_cache;
- name_cache = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "name.cache");
+ std::string name_cache = get_name_cache_filename("name", "cache");
llofstream cache_file(name_cache.c_str());
if(cache_file.is_open())
{