diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 75 |
1 files changed, 43 insertions, 32 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index fe9a17d..6564b4d 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -256,20 +256,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
256 | // If the file is already cached, don't cache it, just touch it so access time is updated | 256 | // If the file is already cached, don't cache it, just touch it so access time is updated |
257 | if (File.Exists(filename)) | 257 | if (File.Exists(filename)) |
258 | { | 258 | { |
259 | // We don't really want to know about sharing | 259 | UpdateFileLastAccessTime(filename); |
260 | // violations here. If the file is locked, then | ||
261 | // the other thread has updated the time for us. | ||
262 | try | ||
263 | { | ||
264 | lock (m_CurrentlyWriting) | ||
265 | { | ||
266 | if (!m_CurrentlyWriting.Contains(filename)) | ||
267 | File.SetLastAccessTime(filename, DateTime.Now); | ||
268 | } | ||
269 | } | ||
270 | catch | ||
271 | { | ||
272 | } | ||
273 | } | 260 | } |
274 | else | 261 | else |
275 | { | 262 | { |
@@ -329,6 +316,24 @@ namespace OpenSim.Region.CoreModules.Asset | |||
329 | } | 316 | } |
330 | 317 | ||
331 | /// <summary> | 318 | /// <summary> |
319 | /// Updates the cached file with the current time. | ||
320 | /// </summary> | ||
321 | /// <param name="filename">Filename.</param> | ||
322 | /// <returns><c>true</c>, if the update was successful, false otherwise.</returns> | ||
323 | private bool UpdateFileLastAccessTime(string filename) | ||
324 | { | ||
325 | try | ||
326 | { | ||
327 | File.SetLastAccessTime(filename, DateTime.Now); | ||
328 | return true; | ||
329 | } | ||
330 | catch | ||
331 | { | ||
332 | return false; | ||
333 | } | ||
334 | } | ||
335 | |||
336 | /// <summary> | ||
332 | /// Try to get an asset from the in-memory cache. | 337 | /// Try to get an asset from the in-memory cache. |
333 | /// </summary> | 338 | /// </summary> |
334 | /// <param name="id"></param> | 339 | /// <param name="id"></param> |
@@ -771,8 +776,8 @@ namespace OpenSim.Region.CoreModules.Asset | |||
771 | { | 776 | { |
772 | UuidGatherer gatherer = new UuidGatherer(m_AssetService); | 777 | UuidGatherer gatherer = new UuidGatherer(m_AssetService); |
773 | 778 | ||
774 | HashSet<UUID> uniqueUuids = new HashSet<UUID>(); | 779 | Dictionary<UUID, sbyte> assetIdsToCheck = new Dictionary<UUID, sbyte>(); |
775 | Dictionary<UUID, sbyte> assets = new Dictionary<UUID, sbyte>(); | 780 | Dictionary<UUID, bool> assetsFound = new Dictionary<UUID, bool>(); |
776 | 781 | ||
777 | foreach (Scene s in m_Scenes) | 782 | foreach (Scene s in m_Scenes) |
778 | { | 783 | { |
@@ -780,34 +785,40 @@ namespace OpenSim.Region.CoreModules.Asset | |||
780 | 785 | ||
781 | s.ForEachSOG(delegate(SceneObjectGroup e) | 786 | s.ForEachSOG(delegate(SceneObjectGroup e) |
782 | { | 787 | { |
783 | gatherer.GatherAssetUuids(e, assets); | 788 | gatherer.GatherAssetUuids(e, assetIdsToCheck); |
784 | 789 | ||
785 | foreach (UUID assetID in assets.Keys) | 790 | foreach (UUID assetID in assetIdsToCheck.Keys) |
786 | { | 791 | { |
787 | uniqueUuids.Add(assetID); | 792 | if (!assetsFound.ContainsKey(assetID)) |
788 | |||
789 | string filename = GetFileName(assetID.ToString()); | ||
790 | |||
791 | if (File.Exists(filename)) | ||
792 | { | 793 | { |
793 | File.SetLastAccessTime(filename, DateTime.Now); | 794 | string filename = GetFileName(assetID.ToString()); |
795 | |||
796 | if (File.Exists(filename)) | ||
797 | { | ||
798 | UpdateFileLastAccessTime(filename); | ||
799 | } | ||
800 | else if (storeUncached) | ||
801 | { | ||
802 | AssetBase cachedAsset = m_AssetService.Get(assetID.ToString()); | ||
803 | if (cachedAsset == null && assetIdsToCheck[assetID] != (sbyte)AssetType.Unknown) | ||
804 | assetsFound[assetID] = false; | ||
805 | else | ||
806 | assetsFound[assetID] = true; | ||
807 | } | ||
794 | } | 808 | } |
795 | else if (storeUncached) | 809 | else if (!assetsFound[assetID]) |
796 | { | 810 | { |
797 | AssetBase cachedAsset = m_AssetService.Get(assetID.ToString()); | 811 | m_log.DebugFormat( |
798 | if (cachedAsset == null && assets[assetID] != (sbyte)AssetType.Unknown) | ||
799 | m_log.DebugFormat( | ||
800 | "[FLOTSAM ASSET CACHE]: Could not find asset {0}, type {1} referenced by object {2} at {3} in scene {4} when pre-caching all scene assets", | 812 | "[FLOTSAM ASSET CACHE]: Could not find asset {0}, type {1} referenced by object {2} at {3} in scene {4} when pre-caching all scene assets", |
801 | assetID, assets[assetID], e.Name, e.AbsolutePosition, s.Name); | 813 | assetID, assetIdsToCheck[assetID], e.Name, e.AbsolutePosition, s.Name); |
802 | } | 814 | } |
803 | } | 815 | } |
804 | 816 | ||
805 | assets.Clear(); | 817 | assetIdsToCheck.Clear(); |
806 | }); | 818 | }); |
807 | } | 819 | } |
808 | 820 | ||
809 | 821 | return assetsFound.Count; | |
810 | return uniqueUuids.Count; | ||
811 | } | 822 | } |
812 | 823 | ||
813 | /// <summary> | 824 | /// <summary> |