diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 7e57275f17..c5cffa3e3f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -161,18 +161,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver return item; } - public void Execute() + /// + /// Execute the request + /// + /// + /// A list of the inventory nodes loaded. If folders were loaded then only the root folders are + /// returned + /// + public List Execute() { string filePath = "ERROR"; int successfulAssetRestores = 0; int failedAssetRestores = 0; int successfulItemRestores = 0; + List nodesLoaded = new List(); UserProfileData userProfile = commsManager.UserService.GetUserProfile(m_firstName, m_lastName); if (null == userProfile) { m_log.ErrorFormat("[INVENTORY ARCHIVER]: Failed to find user {0} {1}", m_firstName, m_lastName); - return; + return nodesLoaded; } CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userProfile.ID); @@ -182,7 +190,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver "[INVENTORY ARCHIVER]: Failed to find user info for {0} {1} {2}", m_firstName, m_lastName, userProfile.ID); - return; + return nodesLoaded; } if (!userInfo.HasReceivedInventory) @@ -191,7 +199,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1} {2}", m_firstName, m_lastName, userProfile.ID); - return; + return nodesLoaded; } InventoryFolderImpl inventoryFolder = userInfo.RootFolder.FindFolderByPath(m_invPath); @@ -201,7 +209,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // TODO: Later on, automatically create this folder if it does not exist m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath); - return; + return nodesLoaded; } archive = new TarArchiveReader(m_loadStream); @@ -236,6 +244,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver userInfo.AddItem(item); successfulItemRestores++; + nodesLoaded.Add(item); } } } @@ -244,6 +253,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_log.DebugFormat("[INVENTORY ARCHIVER]: Restored {0} assets", successfulAssetRestores); m_log.InfoFormat("[INVENTORY ARCHIVER]: Restored {0} items", successfulItemRestores); + + return nodesLoaded; } /// diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index ab914c465c..a684b69136 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -31,6 +31,7 @@ using System.Reflection; using log4net; using Nini.Config; using OpenMetaverse; +using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -96,7 +97,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { if (m_scenes.Count > 0) { - new InventoryArchiveReadRequest(firstName, lastName, invPath, loadStream, m_commsManager).Execute(); + InventoryArchiveReadRequest request = + new InventoryArchiveReadRequest(firstName, lastName, invPath, loadStream, m_commsManager); + + UpdateClientWithLoadedNodes(firstName, lastName, request.Execute()); } } @@ -111,20 +115,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver public void DearchiveInventory(string firstName, string lastName, string invPath, string loadPath) { if (m_scenes.Count > 0) - { - new InventoryArchiveReadRequest(firstName, lastName, invPath, loadPath, m_commsManager).Execute(); - } - - /* - foreach (Scene scene in m_scenes.Values) - { - ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); - if (user != null && !user.IsChildAgent) - { - user.ControllingClient.SendBulkUpdateInventory(folderCopy); - } - } - */ + { + InventoryArchiveReadRequest request = + new InventoryArchiveReadRequest(firstName, lastName, invPath, loadPath, m_commsManager); + + UpdateClientWithLoadedNodes(firstName, lastName, request.Execute()); + } } public void ArchiveInventory(string firstName, string lastName, string invPath, string savePath) @@ -175,6 +171,40 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver string savePath = (cmdparams.Length > 5 ? cmdparams[5] : DEFAULT_INV_BACKUP_FILENAME); ArchiveInventory(firstName, lastName, invPath, savePath); - } + } + + /// + /// Notify the client of loaded nodes if they are logged in + /// + /// Can be empty. In which case, nothing happens + private void UpdateClientWithLoadedNodes(string firstName, string lastName, List loadedNodes) + { + if (loadedNodes.Count == 0) + return; + + UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(firstName, lastName); + + if (null == userProfile) + return; + + foreach (Scene scene in m_scenes.Values) + { + ScenePresence user = scene.GetScenePresence(userProfile.ID); + + if (user != null && !user.IsChildAgent) + { + foreach (InventoryNodeBase node in loadedNodes) + { + m_log.DebugFormat( + "[INVENTORY ARCHIVER]: Notifying {0} of loaded inventory node {1}", + user.Name, node.Name); + + user.ControllingClient.SendBulkUpdateInventory(node); + } + + break; + } + } + } } }