From 9177f2871086ba211c9c84490f322cfe8ad74494 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 12 Feb 2009 19:54:19 +0000 Subject: * Make it possible to load and save inventory archives while a user is not logged in on standalone mode but not on grid mode * No user functionality yet --- .../Archiver/InventoryArchiveReadRequest.cs | 23 ++++++-- .../Archiver/InventoryArchiveWriteRequest.cs | 64 +++++++++++++--------- .../Inventory/Archiver/InventoryArchiverModule.cs | 4 +- 3 files changed, 58 insertions(+), 33 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index d8234bc..7189e36 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -170,14 +170,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver int failedAssetRestores = 0; int successfulItemRestores = 0; List nodesLoaded = new List(); - + if (!m_userInfo.HasReceivedInventory) { - m_log.ErrorFormat( - "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}", - m_userInfo.UserProfile.Name, m_userInfo.UserProfile.ID); + // If the region server has access to the user admin service (by which users are created), + // then we'll assume that it's okay to fiddle with the user's inventory even if they are not on the + // server. + // + // 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 == commsManager.UserAdminService) + { + m_log.ErrorFormat( + "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}", + m_userInfo.UserProfile.Name, m_userInfo.UserProfile.ID); - return nodesLoaded; + return nodesLoaded; + } + else + { + m_userInfo.FetchInventory(); + } } InventoryFolderImpl inventoryFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index c00c80f..d916eba 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -183,42 +183,54 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver InventoryFolderImpl inventoryFolder = null; InventoryItemBase inventoryItem = null; - if (m_userInfo.HasReceivedInventory) - { - // Eliminate double slashes and any leading / on the path. This might be better done within InventoryFolderImpl - // itself (possibly at a small loss in efficiency). - string[] components - = m_invPath.Split(new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries); - m_invPath = String.Empty; - foreach (string c in components) + if (!m_userInfo.HasReceivedInventory) + { + // If the region server has access to the user admin service (by which users are created), + // then we'll assume that it's okay to fiddle with the user's inventory even if they are not on the + // server. + // + // 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 == commsManager.UserAdminService) { - m_invPath += c + InventoryFolderImpl.PATH_DELIMITER; - } + m_log.ErrorFormat( + "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}", + m_userInfo.UserProfile.Name, m_userInfo.UserProfile.ID); - // Annoyingly Split actually returns the original string if the input string consists only of delimiters - // Therefore if we still start with a / after the split, then we need the root folder - if (m_invPath.Length == 0) - { - inventoryFolder = m_userInfo.RootFolder; + return; } else { - m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER)); - inventoryFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); + m_userInfo.FetchInventory(); } + } + + // Eliminate double slashes and any leading / on the path. This might be better done within InventoryFolderImpl + // itself (possibly at a small loss in efficiency). + string[] components + = m_invPath.Split(new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries); + m_invPath = String.Empty; + foreach (string c in components) + { + m_invPath += c + InventoryFolderImpl.PATH_DELIMITER; + } - // The path may point to an item instead - if (inventoryFolder == null) - { - inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath); - } + // Annoyingly Split actually returns the original string if the input string consists only of delimiters + // Therefore if we still start with a / after the split, then we need the root folder + if (m_invPath.Length == 0) + { + inventoryFolder = m_userInfo.RootFolder; } else { - m_log.ErrorFormat( - "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}", - m_userInfo.UserProfile.Name, m_userInfo.UserProfile.ID); - return; + m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER)); + inventoryFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); + } + + // The path may point to an item instead + if (inventoryFolder == null) + { + inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath); } if (null == inventoryFolder) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 82ea6cf..7660546 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -66,11 +66,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver private CommunicationsManager m_commsManager; public void Initialise(Scene scene, IConfigSource source) - { + { if (m_scenes.Count == 0) { scene.RegisterModuleInterface(this); - m_commsManager = scene.CommsManager; + m_commsManager = scene.CommsManager; scene.AddCommand( this, "load iar", -- cgit v1.1