diff --git a/indra/llfilesystem/lldiskcache.cpp b/indra/llfilesystem/lldiskcache.cpp index cc842d7aa4..aa4e07a583 100644 --- a/indra/llfilesystem/lldiskcache.cpp +++ b/indra/llfilesystem/lldiskcache.cpp @@ -65,15 +65,8 @@ LLDiskCache::LLDiskCache(const std::string cache_dir, // add static assets into the new cache after clear. // Only missing entries are copied on init, skiplist is setup // For everything we populate FS specific assets to allow future updates - mSkipList.clear(); - auto static_assets_folder = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "fs_static_assets"); - prepopulateCacheWithStatic(static_assets_folder); -#ifdef OPENSIM - // For OPENSIM we need to populate the static assets - static_assets_folder = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "static_assets"); - prepopulateCacheWithStatic(static_assets_folder); -#endif - // + prepopulateCacheWithStatic(); + // } void LLDiskCache::purge() @@ -145,9 +138,9 @@ void LLDiskCache::purge() action = "DELETE:"; // Make sure static assets are not eliminated auto uuid_as_string = gDirUtilp->getBaseFileName(entry.second.second,true); - uuid_as_string = uuid_as_string.substr(mCacheFilenamePrefix.size()+1, 36);// skip "sl_cache_" and trailing "_N" + uuid_as_string = uuid_as_string.substr(mCacheFilenamePrefix.size() + 1, 36);// skip "sl_cache_" and trailing "_N" // LL_INFOS() << "checking UUID=" < Copy static items into cache and add to the skip list that prevents their purging -// Note that there is no de-duplication nor other validation of the list. It should be cleared before calls to prepopulate -void LLDiskCache::prepopulateCacheWithStatic(const std::string& from_folder) +// Note that there is no de-duplication nor other validation of the list. +void LLDiskCache::prepopulateCacheWithStatic() { - if(gDirUtilp->fileExists(from_folder)) + mSkipList.clear(); + + std::vector from_folders; + from_folders.emplace_back(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "fs_static_assets")); +#ifdef OPENSIM + from_folders.emplace_back(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "static_assets")); +#endif + + for (const auto& from_folder : from_folders) { - auto assets_to_copy = gDirUtilp->getFilesInDir(from_folder); - for(auto from_asset_file : assets_to_copy) + if (gDirUtilp->fileExists(from_folder)) { - from_asset_file = from_folder + gDirUtilp->getDirDelimiter() + from_asset_file; - // we store static assets as UUID.asset_type the asset_type is not used in the current simple cache format - auto uuid_as_string{ gDirUtilp->getBaseFileName(from_asset_file, true) }; - auto to_asset_file = metaDataToFilepath(uuid_as_string, LLAssetType::AT_UNKNOWN, std::string()); - if(!gDirUtilp->fileExists(to_asset_file)) + auto assets_to_copy = gDirUtilp->getFilesInDir(from_folder); + for (auto from_asset_file : assets_to_copy) { - LL_INFOS("LLDiskCache") << "Copying static asset " << from_asset_file << " to cache from " << from_folder << LL_ENDL; - if( LLFile::copy(from_asset_file, to_asset_file) != true ) + from_asset_file = from_folder + gDirUtilp->getDirDelimiter() + from_asset_file; + // we store static assets as UUID.asset_type the asset_type is not used in the current simple cache format + auto uuid_as_string{ gDirUtilp->getBaseFileName(from_asset_file, true) }; + auto to_asset_file = metaDataToFilepath(uuid_as_string, LLAssetType::AT_UNKNOWN, std::string()); + if (!gDirUtilp->fileExists(to_asset_file)) { - LL_WARNS("LLDiskCache") << "Failed to copy " << from_asset_file << " to " << to_asset_file << LL_ENDL; + if (mEnableCacheDebugInfo) + { + LL_INFOS("LLDiskCache") << "Copying static asset " << from_asset_file << " to cache from " << from_folder << LL_ENDL; + } + if (!LLFile::copy(from_asset_file, to_asset_file)) + { + LL_WARNS("LLDiskCache") << "Failed to copy " << from_asset_file << " to " << to_asset_file << LL_ENDL; + } + } + if (std::find(mSkipList.begin(), mSkipList.end(), uuid_as_string) == mSkipList.end()) + { + if (mEnableCacheDebugInfo) + { + LL_INFOS("LLDiskCache") << "Adding " << uuid_as_string << " to skip list" << LL_ENDL; + } + mSkipList.emplace_back(uuid_as_string); } - } - if( std::find(mSkipList.begin(), mSkipList.end(), uuid_as_string) == mSkipList.end() ) - { - LL_INFOS() << "Adding " << uuid_as_string << " to skip list" << LL_ENDL; - mSkipList.emplace_back(uuid_as_string); } } } @@ -424,16 +434,7 @@ void LLDiskCache::clearCache() } } // add static assets into the new cache after clear - // For everything we populate FS specific assets to allow future updates - auto static_assets_folder = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "fs_static_assets"); - mSkipList.clear(); - prepopulateCacheWithStatic(static_assets_folder); -#ifdef OPENSIM - // For OPENSIM we need to populate the static assets - static_assets_folder = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "static_assets"); - prepopulateCacheWithStatic(static_assets_folder); -#endif - // + prepopulateCacheWithStatic(); } LL_INFOS() << "Cleared cache " << mCacheDir << LL_ENDL; } diff --git a/indra/llfilesystem/lldiskcache.h b/indra/llfilesystem/lldiskcache.h index 81cb11b881..1164b428e0 100644 --- a/indra/llfilesystem/lldiskcache.h +++ b/indra/llfilesystem/lldiskcache.h @@ -133,7 +133,7 @@ class LLDiskCache : // // copy from distribution into cache to replace static content - void prepopulateCacheWithStatic(const std::string& from_folder); + void prepopulateCacheWithStatic(); // /**