From 762712c02e4abf332d2d9a0ba583d6fe6f406aff Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 9 Dec 2008 18:35:09 +0000 Subject: * Actually update subfolders of parent folders in the inventory cache when a folder gets moved * This was causing inventory folder transfer code to not work properly (this is still temporarily disabled) --- .../Communications/Cache/CachedUserInfo.cs | 34 +++++++++++++++----- .../Communications/Cache/InventoryFolderImpl.cs | 36 ++++++++++++++++++++++ .../Cache/UserProfileCacheService.cs | 4 +-- 3 files changed, 65 insertions(+), 9 deletions(-) (limited to 'OpenSim/Framework/Communications/Cache') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index b4e7bfa..c8656d5 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -397,14 +397,14 @@ namespace OpenSim.Framework.Communications.Cache /// /// Handle a client request to update the inventory folder + /// /// /// If the inventory service has not yet delievered the inventory /// for this user then the request will be queued. /// /// 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. - /// + /// and needs to be changed. /// /// /// @@ -461,6 +461,10 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// + /// + /// true if the delete was successful, or if it was queued pending folder receipt + /// false if the folder to be deleted did not exist. + /// public bool MoveFolder(UUID folderID, UUID parentID) { // m_log.DebugFormat( @@ -482,10 +486,27 @@ namespace OpenSim.Framework.Communications.Cache { m_commsManager.InventoryService.MoveFolder(baseFolder); } - + InventoryFolderImpl folder = RootFolder.FindFolder(folderID); - if (folder != null) - folder.ParentID = parentID; + InventoryFolderImpl parentFolder = RootFolder.FindFolder(parentID); + if (parentFolder != null && folder != null) + { + InventoryFolderImpl oldParentFolder = RootFolder.FindFolder(folder.ParentID); + + if (oldParentFolder != null) + { + oldParentFolder.RemoveChildFolder(folderID); + parentFolder.AddChildFolder(folder); + } + else + { + return false; + } + } + else + { + return false; + } return true; } @@ -502,10 +523,9 @@ namespace OpenSim.Framework.Communications.Cache /// /// This method will delete all the items and folders in the given folder. - /// + /// /// If the inventory service has not yet delievered the inventory /// for this user then the request will be queued. - /// /// /// public bool PurgeFolder(UUID folderID) diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 0704232..83ac239 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -92,6 +92,42 @@ namespace OpenSim.Framework.Communications.Cache return null; } + + /// + /// Add a folder that already exists. + /// + /// + public void AddChildFolder(InventoryFolderImpl folder) + { + lock (SubFolders) + { + folder.ParentID = ID; + SubFolders[folder.ID] = folder; + } + } + + /// + /// Removes the given child subfolder. + /// + /// + /// + /// The folder removed, or null if the folder was not present. + /// + public InventoryFolderImpl RemoveChildFolder(UUID folderID) + { + InventoryFolderImpl removedFolder = null; + + lock (SubFolders) + { + if (SubFolders.ContainsKey(folderID)) + { + removedFolder = SubFolders[folderID]; + SubFolders.Remove(folderID); + } + } + + return removedFolder; + } /// /// Delete all the folders and items in this folder. diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 45102d8..b4f3e9f 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -274,8 +274,8 @@ namespace OpenSim.Framework.Communications.Cache if (!userProfile.MoveFolder(folderID, parentID)) { m_log.ErrorFormat( - "[AGENT INVENTORY]: Failed to move folder for user {0} {1}", - remoteClient.Name, remoteClient.AgentId); + "[AGENT INVENTORY]: Failed to move folder {0} to {1} for user {2}", + folderID, parentID, remoteClient.Name); } } else -- cgit v1.1