* 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)
0.6.1-post-fixes
Justin Clarke Casey 2008-12-09 18:35:09 +00:00
parent 7c3bfdd8c9
commit 762712c02e
3 changed files with 65 additions and 9 deletions

View File

@ -397,6 +397,7 @@ namespace OpenSim.Framework.Communications.Cache
/// <summary> /// <summary>
/// Handle a client request to update the inventory folder /// Handle a client request to update the inventory folder
/// </summary>
/// ///
/// If the inventory service has not yet delievered the inventory /// If the inventory service has not yet delievered the inventory
/// for this user then the request will be queued. /// for this user then the request will be queued.
@ -404,7 +405,6 @@ namespace OpenSim.Framework.Communications.Cache
/// FIXME: We call add new inventory folder because in the data layer, we happen to use an SQL REPLACE /// 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, /// 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.
/// </summary>
/// ///
/// <param name="folderID"></param> /// <param name="folderID"></param>
/// <param name="type"></param> /// <param name="type"></param>
@ -461,6 +461,10 @@ namespace OpenSim.Framework.Communications.Cache
/// ///
/// <param name="folderID"></param> /// <param name="folderID"></param>
/// <param name="parentID"></param> /// <param name="parentID"></param>
/// <returns>
/// true if the delete was successful, or if it was queued pending folder receipt
/// false if the folder to be deleted did not exist.
/// </returns>
public bool MoveFolder(UUID folderID, UUID parentID) public bool MoveFolder(UUID folderID, UUID parentID)
{ {
// m_log.DebugFormat( // m_log.DebugFormat(
@ -484,8 +488,25 @@ namespace OpenSim.Framework.Communications.Cache
} }
InventoryFolderImpl folder = RootFolder.FindFolder(folderID); InventoryFolderImpl folder = RootFolder.FindFolder(folderID);
if (folder != null) InventoryFolderImpl parentFolder = RootFolder.FindFolder(parentID);
folder.ParentID = 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; return true;
} }
@ -502,10 +523,9 @@ namespace OpenSim.Framework.Communications.Cache
/// <summary> /// <summary>
/// This method will delete all the items and folders in the given folder. /// This method will delete all the items and folders in the given folder.
/// /// </summary>
/// If the inventory service has not yet delievered the inventory /// If the inventory service has not yet delievered the inventory
/// for this user then the request will be queued. /// for this user then the request will be queued.
/// </summary>
/// ///
/// <param name="folderID"></param> /// <param name="folderID"></param>
public bool PurgeFolder(UUID folderID) public bool PurgeFolder(UUID folderID)

View File

@ -93,6 +93,42 @@ namespace OpenSim.Framework.Communications.Cache
return null; return null;
} }
/// <summary>
/// Add a folder that already exists.
/// </summary>
/// <param name="folder"></param>
public void AddChildFolder(InventoryFolderImpl folder)
{
lock (SubFolders)
{
folder.ParentID = ID;
SubFolders[folder.ID] = folder;
}
}
/// <summary>
/// Removes the given child subfolder.
/// </summary>
/// <param name="folderID"></param>
/// <returns>
/// The folder removed, or null if the folder was not present.
/// </returns>
public InventoryFolderImpl RemoveChildFolder(UUID folderID)
{
InventoryFolderImpl removedFolder = null;
lock (SubFolders)
{
if (SubFolders.ContainsKey(folderID))
{
removedFolder = SubFolders[folderID];
SubFolders.Remove(folderID);
}
}
return removedFolder;
}
/// <summary> /// <summary>
/// Delete all the folders and items in this folder. /// Delete all the folders and items in this folder.
/// </summary> /// </summary>

View File

@ -274,8 +274,8 @@ namespace OpenSim.Framework.Communications.Cache
if (!userProfile.MoveFolder(folderID, parentID)) if (!userProfile.MoveFolder(folderID, parentID))
{ {
m_log.ErrorFormat( m_log.ErrorFormat(
"[AGENT INVENTORY]: Failed to move folder for user {0} {1}", "[AGENT INVENTORY]: Failed to move folder {0} to {1} for user {2}",
remoteClient.Name, remoteClient.AgentId); folderID, parentID, remoteClient.Name);
} }
} }
else else