diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index fab489dbd4..81f4e0e6c3 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -107,8 +107,6 @@ namespace Flotsam.RegionModules.AssetCache private IAssetService m_AssetService; private List m_Scenes = new List(); - private bool m_DeepScanBeforePurge; - public FlotsamAssetCache() { m_InvalidChars.AddRange(Path.GetInvalidPathChars()); @@ -170,8 +168,6 @@ namespace Flotsam.RegionModules.AssetCache m_CacheDirectoryTierLen = assetConfig.GetInt("CacheDirectoryTierLength", m_CacheDirectoryTierLen); m_CacheWarnAt = assetConfig.GetInt("CacheWarnAt", m_CacheWarnAt); - - m_DeepScanBeforePurge = assetConfig.GetBoolean("DeepScanBeforePurge", m_DeepScanBeforePurge); } m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory {0}", m_CacheDirectory); @@ -506,13 +502,10 @@ namespace Flotsam.RegionModules.AssetCache // Purge all files last accessed prior to this point DateTime purgeLine = DateTime.Now - m_FileExpiration; - // An optional deep scan at this point will ensure assets present in scenes, - // or referenced by objects in the scene, but not recently accessed - // are not purged. - if (m_DeepScanBeforePurge) - { - CacheScenes(); - } + // An asset cache may contain local non-temporary assets that are not in the asset service. Therefore, + // before cleaning up expired files we must scan the objects in the scene to make sure that we retain + // such local assets if they have not been recently accessed. + TouchAllSceneAssets(false); foreach (string dir in Directory.GetDirectories(m_CacheDirectory)) { @@ -705,11 +698,14 @@ namespace Flotsam.RegionModules.AssetCache /// /// Iterates through all Scenes, doing a deep scan through assets - /// to cache all assets present in the scene or referenced by assets - /// in the scene + /// to update the access time of all assets present in the scene or referenced by assets + /// in the scene. /// - /// - private int CacheScenes() + /// + /// If true, then assets scanned which are not found in cache are added to the cache. + /// + /// Number of distinct asset references found in the scene. + private int TouchAllSceneAssets(bool storeUncached) { UuidGatherer gatherer = new UuidGatherer(m_AssetService); @@ -732,7 +728,7 @@ namespace Flotsam.RegionModules.AssetCache { File.SetLastAccessTime(filename, DateTime.Now); } - else + else if (storeUncached) { m_AssetService.Get(assetID.ToString()); } @@ -860,13 +856,14 @@ namespace Flotsam.RegionModules.AssetCache break; - case "assets": - m_log.Info("[FLOTSAM ASSET CACHE]: Caching all assets, in all scenes."); + m_log.Info("[FLOTSAM ASSET CACHE]: Ensuring assets are cached for all scenes."); Util.FireAndForget(delegate { - int assetsCached = CacheScenes(); - m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Completed Scene Caching, {0} assets found.", assetsCached); + int assetReferenceTotal = TouchAllSceneAssets(true); + m_log.InfoFormat( + "[FLOTSAM ASSET CACHE]: Completed check with {0} assets.", + assetReferenceTotal); }); break; diff --git a/bin/config-include/FlotsamCache.ini.example b/bin/config-include/FlotsamCache.ini.example index b9c6d84808..ad74fc14e9 100644 --- a/bin/config-include/FlotsamCache.ini.example +++ b/bin/config-include/FlotsamCache.ini.example @@ -54,10 +54,3 @@ ; Warning level for cache directory size ;CacheWarnAt = 30000 - - ; Perform a deep scan of all assets within all regions, looking for all assets - ; present or referenced. Mark all assets found that are already present in the - ; cache, and request all assets that are found that are not already cached (this - ; will cause those assets to be cached) - ; - DeepScanBeforePurge = true