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