refactor: use direct scene reference in inventory archive read request
							parent
							
								
									8616230fcf
								
							
						
					
					
						commit
						79c22651d7
					
				| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			@ -55,32 +56,33 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
 | 
			
		|||
        private CachedUserInfo m_userInfo;
 | 
			
		||||
        private string m_invPath;
 | 
			
		||||
 | 
			
		||||
        /// <value>
 | 
			
		||||
        /// We only use this to request modules
 | 
			
		||||
        /// </value>
 | 
			
		||||
        protected Scene m_scene;        
 | 
			
		||||
 | 
			
		||||
        /// <value>
 | 
			
		||||
        /// The stream from which the inventory archive will be loaded.
 | 
			
		||||
        /// </value>
 | 
			
		||||
        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;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -69,19 +69,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
 | 
			
		|||
        /// </value>
 | 
			
		||||
        private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>();
 | 
			
		||||
        private Scene m_aScene;
 | 
			
		||||
        
 | 
			
		||||
        /// <value>
 | 
			
		||||
        /// The comms manager we will use for all comms requests
 | 
			
		||||
        /// </value>
 | 
			
		||||
        protected internal CommunicationsManager CommsManager;
 | 
			
		||||
        protected internal IAssetService AssetService;
 | 
			
		||||
 | 
			
		||||
        public void Initialise(Scene scene, IConfigSource source)
 | 
			
		||||
        {            
 | 
			
		||||
            if (m_scenes.Count == 0)
 | 
			
		||||
            {
 | 
			
		||||
                scene.RegisterModuleInterface<IInventoryArchiverModule>(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
 | 
			
		|||
        /// <returns></returns>
 | 
			
		||||
        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(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue