Shuffle stuff around
parent
e6d4f07c2f
commit
a4e0fde3ee
|
|
@ -65,15 +65,8 @@ LLDiskCache::LLDiskCache(const std::string cache_dir,
|
|||
// <FS:Beq> 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
|
||||
// </FS:Beq>
|
||||
prepopulateCacheWithStatic();
|
||||
// </FS:Beq>
|
||||
}
|
||||
|
||||
void LLDiskCache::purge()
|
||||
|
|
@ -145,9 +138,9 @@ void LLDiskCache::purge()
|
|||
action = "DELETE:";
|
||||
// <FS:Beq> 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=" <<uuid_as_string<< LL_ENDL;
|
||||
if( std::find(mSkipList.begin(), mSkipList.end(), uuid_as_string) != mSkipList.end())
|
||||
if (std::find(mSkipList.begin(), mSkipList.end(), uuid_as_string) != mSkipList.end())
|
||||
{
|
||||
// this is one of our protected items so no purging
|
||||
action = "STATIC:";
|
||||
|
|
@ -357,30 +350,47 @@ const std::string LLDiskCache::getCacheInfo()
|
|||
}
|
||||
|
||||
// <FS:Beq> 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<std::string> 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()
|
|||
}
|
||||
}
|
||||
// <FS:Beq> 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
|
||||
// </FS:Beq>
|
||||
prepopulateCacheWithStatic();
|
||||
}
|
||||
LL_INFOS() << "Cleared cache " << mCacheDir << LL_ENDL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ class LLDiskCache :
|
|||
|
||||
// <FS:Beq>
|
||||
// copy from distribution into cache to replace static content
|
||||
void prepopulateCacheWithStatic(const std::string& from_folder);
|
||||
void prepopulateCacheWithStatic();
|
||||
// </FS:Beq>
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue