From 45430a5403ec45abceac123a76cb7a0c61475b5e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 3 May 2008 19:27:34 +0000 Subject: [PATCH] * Refactor: move UpdateFolder into CachedUserInfo --- .../Communications/Cache/CachedUserInfo.cs | 49 +++++++++++++++++-- .../Cache/UserProfileCacheService.cs | 23 ++------- .../InventoryServer/GridInventoryService.cs | 2 +- 3 files changed, 49 insertions(+), 25 deletions(-) diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index f55b492584..35c20021b4 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -37,6 +37,8 @@ namespace OpenSim.Framework.Communications.Cache { internal delegate void CreateInventoryFolderDelegate( string folderName, LLUUID folderID, ushort folderType, LLUUID parentID); + internal delegate void UpdateInventoryFolderDelegate( + string name, LLUUID folderID, ushort type, LLUUID parentID); /// /// Stores user profile and inventory data received from backend services for a particular user. @@ -336,7 +338,7 @@ namespace OpenSim.Framework.Communications.Cache else { m_log.WarnFormat( - "[INVENTORY CACHE]: Tried to create folder {0} {1} but the folder already exists", + "[AGENT INVENTORY]: Tried to create folder {0} {1} but the folder already exists", folderName, folderID); return false; @@ -367,7 +369,7 @@ namespace OpenSim.Framework.Communications.Cache else { m_log.WarnFormat( - "[INVENTORY CACHE]: Tried to create folder {0} {1} but the folder already exists", + "[AGENT INVENTORY]: Tried to create folder {0} {1} but the folder already exists", folderName, folderID); return false; @@ -376,7 +378,7 @@ namespace OpenSim.Framework.Communications.Cache else { m_log.WarnFormat( - "[INVENTORY CACHE]: Could not find parent folder with id {0} in order to create folder {1} {2}", + "[AGENT INVENTORY]: Could not find parent folder with id {0} in order to create folder {1} {2}", parentID, folderName, folderID); return false; @@ -392,9 +394,46 @@ namespace OpenSim.Framework.Communications.Cache return true; } - - return false; } + + /// + /// Handle a client request to update the inventory folder + /// + /// FIXME: We call add new inventory folder because in the data layer, we happen to use an SQL REPLACE + /// so this will work to rename an existing folder. Needless to say, to rely on this is very confusing, + /// and needs to be changed. + /// + /// + /// + /// + /// + public bool UpdateFolder(string name, LLUUID folderID, ushort type, LLUUID parentID) + { +// m_log.DebugFormat( +// "[AGENT INVENTORY]: Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId); + + if (HasInventory) + { + InventoryFolderBase baseFolder = new InventoryFolderBase(); + baseFolder.Owner = m_userProfile.ID; + baseFolder.ID = folderID; + baseFolder.Name = name; + baseFolder.ParentID = parentID; + baseFolder.Type = (short) type; + baseFolder.Version = RootFolder.Version; + + m_commsManager.InventoryService.AddFolder(baseFolder); + } + else + { + AddRequest( + new InventoryRequest( + Delegate.CreateDelegate(typeof(UpdateInventoryFolderDelegate), this, "UpdateFolder"), + new object[] { name, folderID, type, parentID })); + } + + return true; + } /// /// Add an item to the user's inventory diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 71da8dc012..f640fb8521 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -36,8 +36,6 @@ namespace OpenSim.Framework.Communications.Cache { internal delegate void MoveInventoryFolderDelegate(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID); internal delegate void PurgeInventoryDescendentsDelegate(IClientAPI remoteClient, LLUUID folderID); - internal delegate void UpdateInventoryFolderDelegate( - IClientAPI remoteClient, LLUUID folderID, ushort type, string name, LLUUID parentID); /// /// Holds user profile information and retrieves it from backend services. @@ -198,24 +196,11 @@ namespace OpenSim.Framework.Communications.Cache if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) { - if (userProfile.HasInventory) + if (!userProfile.UpdateFolder(name, folderID, type, parentID)) { - InventoryFolderBase baseFolder = new InventoryFolderBase(); - baseFolder.Owner = remoteClient.AgentId; - baseFolder.ID = folderID; - baseFolder.Name = name; - baseFolder.ParentID = parentID; - baseFolder.Type = (short) type; - baseFolder.Version = userProfile.RootFolder.Version; - - m_commsManager.InventoryService.AddFolder(baseFolder); - } - else - { - userProfile.AddRequest( - new InventoryRequest( - Delegate.CreateDelegate(typeof(UpdateInventoryFolderDelegate), this, "HandleUpdateInventoryFolder"), - new object[] { remoteClient, folderID, type, name, parentID })); + m_log.ErrorFormat( + "[AGENT INVENTORY]: Failed to create folder for user {0} {1}", + remoteClient.Name, remoteClient.AgentId); } } else diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs index f0eef315de..4864185dde 100644 --- a/OpenSim/Grid/InventoryServer/GridInventoryService.cs +++ b/OpenSim/Grid/InventoryServer/GridInventoryService.cs @@ -62,7 +62,7 @@ namespace OpenSim.Grid.InventoryServer m_log.InfoFormat("[GRID AGENT INVENTORY]: Processing request for inventory of {0}", userID); // uncomment me to simulate an overloaded inventory server - //Thread.Sleep(20000); + //Thread.Sleep(18000); InventoryCollection invCollection = new InventoryCollection();