diff options
author | andreykproductengine <akleshchev@productengine.com> | 2016-04-01 21:16:07 +0300 |
---|---|---|
committer | andreykproductengine <akleshchev@productengine.com> | 2016-04-01 21:16:07 +0300 |
commit | 352403b0e28ff545099fe234a02f507388477704 (patch) | |
tree | 11dbed4792e355cc15fee875bc7cf3976849a35c /indra/newview | |
parent | 56f251fb4422e77c856e3968434ff736fda5a43f (diff) |
MAINT-6272 Viewer inventory cache bug
Diffstat (limited to 'indra/newview')
-rwxr-xr-x | indra/newview/llinventorymodel.cpp | 39 | ||||
-rwxr-xr-x | indra/newview/llinventorymodel.h | 4 |
2 files changed, 31 insertions, 12 deletions
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 908f7125df..cada2d7cf2 100755 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -44,6 +44,7 @@ #include "llmarketplacefunctions.h" #include "llwindow.h" #include "llviewercontrol.h" +#include "llviewernetwork.h" #include "llpreview.h" #include "llviewermessage.h" #include "llviewerfoldertype.h" @@ -73,7 +74,8 @@ BOOL LLInventoryModel::sFirstTimeInViewer2 = TRUE; ///---------------------------------------------------------------------------- //BOOL decompress_file(const char* src_filename, const char* dst_filename); -static const char CACHE_FORMAT_STRING[] = "%s.inv"; +static const char PRODUCTION_CACHE_FORMAT_STRING[] = "%s.inv"; +static const char GRID_CACHE_FORMAT_STRING[] = "%s.%s.inv"; static const char * const LOG_INV("Inventory"); struct InventoryIDPtrLess @@ -1623,6 +1625,29 @@ bool LLInventoryModel::fetchDescendentsOf(const LLUUID& folder_id) const return cat->fetch(); } +//static +std::string LLInventoryModel::getInvCacheAddres(const LLUUID& owner_id) +{ + std::string inventory_addr; + std::string owner_id_str; + owner_id.toString(owner_id_str); + std::string path(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, owner_id_str)); + if (LLGridManager::getInstance()->isInProductionGrid()) + { + inventory_addr = llformat(PRODUCTION_CACHE_FORMAT_STRING, path.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); + inventory_addr = llformat(GRID_CACHE_FORMAT_STRING, path.c_str(), grid_id_lower.c_str()); + } + return inventory_addr; +} + void LLInventoryModel::cache( const LLUUID& parent_folder_id, const LLUUID& agent_id) @@ -1643,11 +1668,7 @@ void LLInventoryModel::cache( items, INCLUDE_TRASH, can_cache); - std::string agent_id_str; - std::string inventory_filename; - agent_id.toString(agent_id_str); - std::string path(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, agent_id_str)); - inventory_filename = llformat(CACHE_FORMAT_STRING, path.c_str()); + std::string inventory_filename = getInvCacheAddres(agent_id); saveToFile(inventory_filename, categories, items); std::string gzip_filename(inventory_filename); gzip_filename.append(".gz"); @@ -1951,11 +1972,7 @@ bool LLInventoryModel::loadSkeleton( item_array_t items; item_array_t possible_broken_links; cat_set_t invalid_categories; // Used to mark categories that weren't successfully loaded. - std::string owner_id_str; - owner_id.toString(owner_id_str); - std::string path(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, owner_id_str)); - std::string inventory_filename; - inventory_filename = llformat(CACHE_FORMAT_STRING, path.c_str()); + std::string inventory_filename = getInvCacheAddres(owner_id); const S32 NO_VERSION = LLViewerInventoryCategory::VERSION_UNKNOWN; std::string gzip_filename(inventory_filename); gzip_filename.append(".gz"); diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h index 86c6df3323..3004eaf7c1 100755 --- a/indra/newview/llinventorymodel.h +++ b/indra/newview/llinventorymodel.h @@ -164,7 +164,9 @@ public: bool loadSkeleton(const LLSD& options, const LLUUID& owner_id); void buildParentChildMap(); // brute force method to rebuild the entire parent-child relations void createCommonSystemCategories(); - + + static std::string getInvCacheAddres(const LLUUID& owner_id); + // Call on logout to save a terse representation. void cache(const LLUUID& parent_folder_id, const LLUUID& agent_id); private: |