aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs')
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs37
1 files changed, 17 insertions, 20 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index e1d4d78..d1a563c 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -107,8 +107,6 @@ namespace OpenSim.Region.CoreModules.Asset
107 private IAssetService m_AssetService; 107 private IAssetService m_AssetService;
108 private List<Scene> m_Scenes = new List<Scene>(); 108 private List<Scene> m_Scenes = new List<Scene>();
109 109
110 private bool m_DeepScanBeforePurge;
111
112 public FlotsamAssetCache() 110 public FlotsamAssetCache()
113 { 111 {
114 m_InvalidChars.AddRange(Path.GetInvalidPathChars()); 112 m_InvalidChars.AddRange(Path.GetInvalidPathChars());
@@ -170,8 +168,6 @@ namespace OpenSim.Region.CoreModules.Asset
170 m_CacheDirectoryTierLen = assetConfig.GetInt("CacheDirectoryTierLength", m_CacheDirectoryTierLen); 168 m_CacheDirectoryTierLen = assetConfig.GetInt("CacheDirectoryTierLength", m_CacheDirectoryTierLen);
171 169
172 m_CacheWarnAt = assetConfig.GetInt("CacheWarnAt", m_CacheWarnAt); 170 m_CacheWarnAt = assetConfig.GetInt("CacheWarnAt", m_CacheWarnAt);
173
174 m_DeepScanBeforePurge = assetConfig.GetBoolean("DeepScanBeforePurge", m_DeepScanBeforePurge);
175 } 171 }
176 172
177 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory {0}", m_CacheDirectory); 173 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory {0}", m_CacheDirectory);
@@ -519,13 +515,10 @@ namespace OpenSim.Region.CoreModules.Asset
519 // Purge all files last accessed prior to this point 515 // Purge all files last accessed prior to this point
520 DateTime purgeLine = DateTime.Now - m_FileExpiration; 516 DateTime purgeLine = DateTime.Now - m_FileExpiration;
521 517
522 // An optional deep scan at this point will ensure assets present in scenes, 518 // An asset cache may contain local non-temporary assets that are not in the asset service. Therefore,
523 // or referenced by objects in the scene, but not recently accessed 519 // before cleaning up expired files we must scan the objects in the scene to make sure that we retain
524 // are not purged. 520 // such local assets if they have not been recently accessed.
525 if (m_DeepScanBeforePurge) 521 TouchAllSceneAssets(false);
526 {
527 CacheScenes();
528 }
529 522
530 foreach (string dir in Directory.GetDirectories(m_CacheDirectory)) 523 foreach (string dir in Directory.GetDirectories(m_CacheDirectory))
531 { 524 {
@@ -718,11 +711,14 @@ namespace OpenSim.Region.CoreModules.Asset
718 711
719 /// <summary> 712 /// <summary>
720 /// Iterates through all Scenes, doing a deep scan through assets 713 /// Iterates through all Scenes, doing a deep scan through assets
721 /// to cache all assets present in the scene or referenced by assets 714 /// to update the access time of all assets present in the scene or referenced by assets
722 /// in the scene 715 /// in the scene.
723 /// </summary> 716 /// </summary>
724 /// <returns></returns> 717 /// <param name="storeUncached">
725 private int CacheScenes() 718 /// If true, then assets scanned which are not found in cache are added to the cache.
719 /// </param>
720 /// <returns>Number of distinct asset references found in the scene.</returns>
721 private int TouchAllSceneAssets(bool storeUncached)
726 { 722 {
727 UuidGatherer gatherer = new UuidGatherer(m_AssetService); 723 UuidGatherer gatherer = new UuidGatherer(m_AssetService);
728 724
@@ -745,7 +741,7 @@ namespace OpenSim.Region.CoreModules.Asset
745 { 741 {
746 File.SetLastAccessTime(filename, DateTime.Now); 742 File.SetLastAccessTime(filename, DateTime.Now);
747 } 743 }
748 else 744 else if (storeUncached)
749 { 745 {
750 m_AssetService.Get(assetID.ToString()); 746 m_AssetService.Get(assetID.ToString());
751 } 747 }
@@ -873,13 +869,14 @@ namespace OpenSim.Region.CoreModules.Asset
873 869
874 break; 870 break;
875 871
876
877 case "assets": 872 case "assets":
878 m_log.Info("[FLOTSAM ASSET CACHE]: Caching all assets, in all scenes."); 873 m_log.Info("[FLOTSAM ASSET CACHE]: Ensuring assets are cached for all scenes.");
879 874
880 Util.FireAndForget(delegate { 875 Util.FireAndForget(delegate {
881 int assetsCached = CacheScenes(); 876 int assetReferenceTotal = TouchAllSceneAssets(true);
882 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Completed Scene Caching, {0} assets found.", assetsCached); 877 m_log.InfoFormat(
878 "[FLOTSAM ASSET CACHE]: Completed check with {0} assets.",
879 assetReferenceTotal);
883 }); 880 });
884 881
885 break; 882 break;