From 79c22651d7673b61a0c62786eb16f8b6433d6928 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sun, 6 Sep 2009 20:16:56 +0100 Subject: refactor: use direct scene reference in inventory archive read request --- .../Archiver/InventoryArchiveReadRequest.cs | 26 ++++++++++++---------- .../Archiver/InventoryArchiveWriteRequest.cs | 3 +-- .../Inventory/Archiver/InventoryArchiverModule.cs | 20 +++++------------ .../Archiver/Tests/InventoryArchiverTests.cs | 2 +- 4 files changed, 21 insertions(+), 30 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 38bd149..bb40450 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -42,6 +42,7 @@ using OpenSim.Framework.Communications.Osp; using OpenSim.Framework.Serialization; using OpenSim.Framework.Serialization.External; using OpenSim.Region.CoreModules.World.Archiver; +using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver @@ -56,31 +57,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver private string m_invPath; /// + /// We only use this to request modules + /// + protected Scene m_scene; + + /// /// The stream from which the inventory archive will be loaded. /// private Stream m_loadStream; - protected CommunicationsManager m_commsManager; - protected IAssetService m_assetService; - public InventoryArchiveReadRequest( - CachedUserInfo userInfo, string invPath, string loadPath, CommunicationsManager commsManager, IAssetService assetService) + Scene scene, CachedUserInfo userInfo, string invPath, string loadPath) : this( + scene, userInfo, invPath, - new GZipStream(new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress), - commsManager, assetService) + new GZipStream(new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress)) { } public InventoryArchiveReadRequest( - CachedUserInfo userInfo, string invPath, Stream loadStream, CommunicationsManager commsManager, IAssetService assetService) + Scene scene, CachedUserInfo userInfo, string invPath, Stream loadStream) { + m_scene = scene; m_userInfo = userInfo; m_invPath = invPath; m_loadStream = loadStream; - m_commsManager = commsManager; - m_assetService = assetService; } /// @@ -106,7 +108,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might // use a remote inventory service, though this is vanishingly rare at the moment. - if (null == m_commsManager.UserAdminService) + if (null == m_scene.CommsManager.UserAdminService) { m_log.ErrorFormat( "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}", @@ -167,7 +169,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // Don't use the item ID that's in the file item.ID = UUID.Random(); - UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_commsManager); + UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.CommsManager); if (UUID.Zero != ospResolvedId) item.CreatorIdAsUuid = ospResolvedId; @@ -371,7 +373,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver asset.Type = assetType; asset.Data = data; - m_assetService.Store(asset); + m_scene.AssetService.Store(asset); return true; } diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index da54469..badabe0 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -39,7 +39,6 @@ using OpenSim.Framework.Serialization.External; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Osp; -using OpenSim.Region.Framework.Scenes; using OpenSim.Region.CoreModules.World.Archiver; using OpenSim.Region.Framework.Scenes; @@ -114,7 +113,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_userInfo = userInfo; m_invPath = invPath; m_saveStream = saveStream; - m_assetGatherer = new UuidGatherer(m_module.AssetService); + m_assetGatherer = new UuidGatherer(m_scene.AssetService); } protected void ReceivedAllAssets(ICollection assetsFoundUuids, ICollection assetsNotFoundUuids) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 36e17b4..2c36270 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -69,19 +69,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// private Dictionary m_scenes = new Dictionary(); private Scene m_aScene; - - /// - /// The comms manager we will use for all comms requests - /// - protected internal CommunicationsManager CommsManager; - protected internal IAssetService AssetService; public void Initialise(Scene scene, IConfigSource source) { if (m_scenes.Count == 0) { scene.RegisterModuleInterface(this); - CommsManager = scene.CommsManager; OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted; scene.AddCommand( @@ -99,11 +92,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_scenes[scene.RegionInfo.RegionID] = scene; } - - public void PostInitialise() - { - AssetService = m_aScene.AssetService; - } + + public void PostInitialise() {} public void Close() {} @@ -150,7 +140,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (userInfo != null) { InventoryArchiveReadRequest request = - new InventoryArchiveReadRequest(userInfo, invPath, loadStream, CommsManager, AssetService); + new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream); UpdateClientWithLoadedNodes(userInfo, request.Execute()); } } @@ -165,7 +155,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (userInfo != null) { InventoryArchiveReadRequest request = - new InventoryArchiveReadRequest(userInfo, invPath, loadPath, CommsManager, AssetService); + new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath); UpdateClientWithLoadedNodes(userInfo, request.Execute()); } } @@ -261,7 +251,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// protected CachedUserInfo GetUserInfo(string firstName, string lastName) { - CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); + CachedUserInfo userInfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); if (null == userInfo) { m_log.ErrorFormat( diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 2ad6f1a..cf9fcaa 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -412,7 +412,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); - new InventoryArchiveReadRequest(userInfo, null, (Stream)null, null, null) + new InventoryArchiveReadRequest(scene, userInfo, null, (Stream)null) .ReplicateArchivePathToUserInventory( itemArchivePath, false, userInfo.RootFolder, foldersCreated, nodesLoaded); -- cgit v1.1