From 85e1555478a0d43650f3eb418a676e3acba185b7 Mon Sep 17 00:00:00 2001 From: Rye Mutt <rye@alchemyviewer.org> Date: Mon, 21 Mar 2022 01:50:24 -0400 Subject: [PATCH] Start to separate files out cache files from different grids --- indra/llfilesystem/lldir.cpp | 27 +++++++++---- indra/llfilesystem/lldir.h | 5 ++- indra/llmessage/llexperiencecache.cpp | 20 +++++++++- indra/llmessage/llexperiencecache.h | 4 +- indra/newview/llappviewer.cpp | 56 ++++++++++++++++++++++++--- indra/newview/llstartup.cpp | 7 +++- 6 files changed, 98 insertions(+), 21 deletions(-) diff --git a/indra/llfilesystem/lldir.cpp b/indra/llfilesystem/lldir.cpp index d26eb115421..fed9c2e5041 100644 --- a/indra/llfilesystem/lldir.cpp +++ b/indra/llfilesystem/lldir.cpp @@ -89,7 +89,8 @@ LLDir::LLDir() mTempDir(""), mDirDelimiter("/"), // fallback to forward slash if not overridden mLanguage("en"), - mUserName("undefined") + mUserName("undefined"), + mGrid("") { } @@ -916,7 +917,7 @@ std::string LLDir::getForbiddenFileChars() return "\\/:*?\"<>|"; } -void LLDir::setLindenUserDir(const std::string &username) +void LLDir::setLindenUserDir(const std::string &username, const std::string &gridname) { // if the username isn't set, that's bad if (!username.empty()) @@ -926,7 +927,13 @@ void LLDir::setLindenUserDir(const std::string &username) std::string userlower(username); LLStringUtil::toLower(userlower); LLStringUtil::replaceChar(userlower, ' ', '_'); - mLindenUserDir = add(getOSUserAppDir(), userlower); + std::string gridlower(gridname); + LLStringUtil::toLower(gridlower); + LLStringUtil::replaceChar(gridlower, ' ', '_'); + const std::string& logname = (gridlower.empty()) + ? userlower : userlower.append(".").append(gridlower); + + mLindenUserDir = add(getOSUserAppDir(), logname); } else { @@ -950,10 +957,12 @@ void LLDir::setChatLogsDir(const std::string &path) void LLDir::updatePerAccountChatLogsDir() { - mPerAccountChatLogsDir = add(getChatLogsDir(), mUserName); + const std::string& logname = (mGrid.empty()) + ? mUserName : mUserName.append(".").append(mGrid); + mPerAccountChatLogsDir = add(getChatLogsDir(), logname); } -void LLDir::setPerAccountChatLogsDir(const std::string &username) +void LLDir::setPerAccountChatLogsDir(const std::string &username, const std::string &gridname) { // if both first and last aren't set, assume we're grabbing the cached dir if (!username.empty()) @@ -963,8 +972,12 @@ void LLDir::setPerAccountChatLogsDir(const std::string &username) std::string userlower(username); LLStringUtil::toLower(userlower); LLStringUtil::replaceChar(userlower, ' ', '_'); - + std::string gridlower(gridname); + LLStringUtil::toLower(gridlower); + LLStringUtil::replaceChar(gridlower, ' ', '_'); + mUserName = userlower; + mGrid = gridlower; updatePerAccountChatLogsDir(); } else @@ -1033,7 +1046,7 @@ bool LLDir::setCacheDir(const std::string &path) if (path.empty() ) { // reset to default - mCacheDir = ""; + mCacheDir.clear(); return true; } else diff --git a/indra/llfilesystem/lldir.h b/indra/llfilesystem/lldir.h index 99e6ffb8baf..9035786e815 100644 --- a/indra/llfilesystem/lldir.h +++ b/indra/llfilesystem/lldir.h @@ -184,8 +184,8 @@ class LLDir virtual void setChatLogsDir(const std::string &path); // Set the chat logs dir to this user's dir - virtual void setPerAccountChatLogsDir(const std::string &username); // Set the per user chat log directory. - virtual void setLindenUserDir(const std::string &username); // Set the linden user dir to this user's dir + virtual void setPerAccountChatLogsDir(const std::string &username, const std::string &gridname); // Set the per user chat log directory. + virtual void setLindenUserDir(const std::string &username, const std::string &gridname); // Set the linden user dir to this user's dir virtual void setSkinFolder(const std::string &skin_folder, const std::string& language); virtual std::string getSkinFolder() const; virtual std::string getLanguage() const; @@ -269,6 +269,7 @@ class LLDir std::string mLLPluginDir; // Location for plugins and plugin shell static std::string sDumpDir; // Per-run crash report subdir of log directory. std::string mUserName; // Current user name + std::string mGrid; // Current grid }; void dir_exists_or_crash(const std::string &dir_name); diff --git a/indra/llmessage/llexperiencecache.cpp b/indra/llmessage/llexperiencecache.cpp index 6224e45be0f..c5967f4d02b 100644 --- a/indra/llmessage/llexperiencecache.cpp +++ b/indra/llmessage/llexperiencecache.cpp @@ -88,10 +88,26 @@ const int LLExperienceCache::SEARCH_PAGE_SIZE = 30; bool LLExperienceCache::sShutdown = false; //========================================================================= -void LLExperienceCache::initSingleton() +LLExperienceCache::LLExperienceCache(std::string grid) { - mCacheFileName = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "experience_cache.xml"); + LLStringUtil::toLower(grid); + LLStringUtil::replaceChar(grid, ' ', '_'); + std::string file; + if (grid.empty()) + { + file = "experience_cache.xml"; + } + else + { + file = llformat("experience_cache.%s.xml", grid); + } + + mCacheFileName = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, file); +} + +void LLExperienceCache::initSingleton() +{ LL_INFOS("ExperienceCache") << "Loading " << mCacheFileName << LL_ENDL; llifstream cache_stream(mCacheFileName.c_str()); diff --git a/indra/llmessage/llexperiencecache.h b/indra/llmessage/llexperiencecache.h index b1fe4348a7e..8f38ac316c6 100644 --- a/indra/llmessage/llexperiencecache.h +++ b/indra/llmessage/llexperiencecache.h @@ -41,9 +41,9 @@ class LLSD; class LLUUID; -class LLExperienceCache final : public LLSingleton < LLExperienceCache > +class LLExperienceCache final : public LLParamSingleton < LLExperienceCache > { - LLSINGLETON_EMPTY_CTOR(LLExperienceCache); + LLSINGLETON(LLExperienceCache, std::string); public: typedef boost::function<std::string(const std::string &)> CapabilityQuery_t; diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 017b9c7627c..3a29a07a97f 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -4580,8 +4580,19 @@ void LLAppViewer::saveFinalSnapshot() void LLAppViewer::loadNameCache() { // display names cache + std::string file; + if (LLGridManager::getInstance()->isInSecondlife()) + { + file = "avatar_name_cache.xml"; + } + else + { + std::string gridlabel = LLGridManager::getInstance()->getGridId(); + LLStringUtil::toLower(gridlabel); + file = llformat("avatar_name_cache.%s.xml", gridlabel.c_str()); + } std::string filename = - gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "avatar_name_cache.xml"); + gDirUtilp->getExpandedFilename(LL_PATH_CACHE, file); LL_INFOS("AvNameCache") << filename << LL_ENDL; llifstream name_cache_stream(filename.c_str()); if(name_cache_stream.is_open()) @@ -4596,8 +4607,19 @@ void LLAppViewer::loadNameCache() if (!gCacheName) return; - std::string name_cache; - name_cache = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "name.cache"); + std::string name_file; + if (LLGridManager::getInstance()->isInSecondlife()) + { + name_file = "name.cache"; + } + else + { + std::string gridid = LLGridManager::getInstance()->getGridId(); + LLStringUtil::toLower(gridid); + name_file = llformat("name.%s.cache", gridid.c_str()); + } + + std::string name_cache = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, name_file); llifstream cache_file(name_cache.c_str()); if(cache_file.is_open()) { @@ -4608,8 +4630,19 @@ void LLAppViewer::loadNameCache() void LLAppViewer::saveNameCache() { // display names cache + std::string file; + if (LLGridManager::getInstance()->isInSecondlife()) + { + file = "avatar_name_cache.xml"; + } + else + { + std::string gridlabel = LLGridManager::getInstance()->getGridId(); + LLStringUtil::toLower(gridlabel); + file = llformat("avatar_name_cache.%s.xml", gridlabel.c_str()); + } std::string filename = - gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "avatar_name_cache.xml"); + gDirUtilp->getExpandedFilename(LL_PATH_CACHE, file); llofstream name_cache_stream(filename.c_str()); if(name_cache_stream.is_open()) { @@ -4619,8 +4652,19 @@ void LLAppViewer::saveNameCache() // real names cache if (gCacheName) { - std::string name_cache; - name_cache = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "name.cache"); + std::string name_file; + if (LLGridManager::getInstance()->isInSecondlife()) + { + name_file = "name.cache"; + } + else + { + std::string gridid = LLGridManager::getInstance()->getGridId(); + LLStringUtil::toLower(gridid); + name_file = llformat("name.%s.cache", gridid.c_str()); + } + + std::string name_cache = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, name_file); llofstream cache_file(name_cache.c_str()); if(cache_file.is_open()) { diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index f32bbad72ab..ed87dceece8 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -947,7 +947,8 @@ bool idle_startup() // create necessary directories // *FIX: these mkdir's should error check - gDirUtilp->setLindenUserDir(userid); + const std::string& gridlabel = !LLGridManager::getInstance()->isInSecondlife() ? LLGridManager::getInstance()->getGridId() : LLStringUtil::null; + gDirUtilp->setLindenUserDir(userid, gridlabel); LLFile::mkdir(gDirUtilp->getLindenUserDir()); // As soon as directories are ready initialize notification storages @@ -995,7 +996,7 @@ bool idle_startup() { gDirUtilp->setChatLogsDir(gSavedPerAccountSettings.getString("InstantMessageLogPath")); } - gDirUtilp->setPerAccountChatLogsDir(userid); + gDirUtilp->setPerAccountChatLogsDir(userid, gridlabel); LLFile::mkdir(gDirUtilp->getChatLogsDir()); LLFile::mkdir(gDirUtilp->getPerAccountChatLogsDir()); @@ -2934,6 +2935,8 @@ void LLStartUp::initNameCache() void LLStartUp::initExperiences() { // Should trigger loading the cache. + const std::string& gridlabel = !LLGridManager::getInstance()->isInSecondlife() ? LLGridManager::getInstance()->getGridId() : LLStringUtil::null; + LLExperienceCache::initParamSingleton(gridlabel); LLExperienceCache::instance().setCapabilityQuery( boost::bind(&LLAgent::getRegionCapability, &gAgent, _1)); -- GitLab