From 9208fb5d543e5dd226d8d900c78a5056fea4f022 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 4 Dec 2014 23:55:59 +0000 Subject: [PATCH] refactor: Make IteratingUUIDGatherer take a dictionary in its constructor like UUIDGatherer, so we can deal with future cases where the dictionary may already be pre-populated. --- .../EntityTransfer/HGEntityTransferModule.cs | 6 ++-- .../Region/Framework/Scenes/UuidGatherer.cs | 32 +++++++++++++------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 97267c1cd7..fc932b05f3 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -604,7 +604,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // "[HG ENTITY TRANSFER MODULE]: Incoming attachment {0} for HG user {1} with asset service {2}", // so.Name, so.AttachedAvatar, url); - IteratingHGUuidGatherer uuidGatherer = new IteratingHGUuidGatherer(Scene.AssetService, url); + IDictionary ids = new Dictionary(); + IteratingHGUuidGatherer uuidGatherer + = new IteratingHGUuidGatherer(Scene.AssetService, url, ids); uuidGatherer.RecordAssetUuids(so); while (!uuidGatherer.Complete) @@ -632,8 +634,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } } - IDictionary ids = uuidGatherer.GetGatheredUuids(); - // m_log.DebugFormat( // "[HG ENTITY TRANSFER]: Fetching {0} assets for attachment {1} for HG user {2} with asset service {3}", // ids.Count, so.Name, so.OwnerID, url); diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 2450cdbb84..cacacf8791 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs @@ -648,6 +648,15 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// Gather uuids for a given entity. + /// + /// + /// This does a deep inspection of the entity to retrieve all the assets it uses (whether as textures, as scripts + /// contained in inventory, as scripts contained in objects contained in another object's inventory, etc. Assets + /// are only retrieved when they are necessary to carry out the inspection (i.e. a serialized object needs to be + /// retrieved to work out which assets it references). + /// public class IteratingUuidGatherer { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -678,20 +687,25 @@ namespace OpenSim.Region.Framework.Scenes protected Queue m_assetUuidsToInspect; - public IteratingUuidGatherer(IAssetService assetService) + /// + /// Initializes a new instance of the class. + /// + /// + /// Asset service. + /// + /// + /// Gathered UUIDs will be collected in this dictinaory. + /// It can be pre-populated if you want to stop the gatherer from analyzing assets that have already been fetched and inspected. + /// + public IteratingUuidGatherer(IAssetService assetService, IDictionary collector) { m_assetService = assetService; - m_gatheredAssetUuids = new Dictionary(); + m_gatheredAssetUuids = collector; // FIXME: Not efficient for searching, can improve. m_assetUuidsToInspect = new Queue(); } - public IDictionary GetGatheredUuids() - { - return new Dictionary(m_gatheredAssetUuids); - } - public bool AddAssetUuidToInspect(UUID uuid) { if (m_assetUuidsToInspect.Contains(uuid)) @@ -1147,8 +1161,8 @@ namespace OpenSim.Region.Framework.Scenes protected string m_assetServerURL; - public IteratingHGUuidGatherer(IAssetService assetService, string assetServerURL) - : base(assetService) + public IteratingHGUuidGatherer(IAssetService assetService, string assetServerURL, IDictionary collector) + : base(assetService, collector) { m_assetServerURL = assetServerURL; if (!m_assetServerURL.EndsWith("/") && !m_assetServerURL.EndsWith("="))