diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
index 6a7b6b7c47..84e42a37d1 100644
--- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
+++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
@@ -35,7 +35,8 @@ using log4net;
namespace OpenSim.Framework.Communications.Cache
{
- //internal delegate void DeleteItemDelegate(
+ internal delegate void DeleteItemDelegate(LLUUID itemID);
+
internal delegate void CreateFolderDelegate(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID);
internal delegate void MoveFolderDelegate(LLUUID folderID, LLUUID parentID);
internal delegate void PurgeFolderDelegate(LLUUID folderID);
@@ -306,7 +307,10 @@ namespace OpenSim.Framework.Communications.Cache
}
///
- /// Create a folder in this agent's inventory
+ /// Create a folder in this agent's inventory.
+ ///
+ /// If the inventory service has not yet delievered the inventory
+ /// for this user then the request will be queued.
///
///
///
@@ -399,10 +403,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.
///
+ ///
///
///
///
@@ -437,7 +445,11 @@ namespace OpenSim.Framework.Communications.Cache
///
/// Handle an inventory folder move request from the client.
+ ///
+ /// If the inventory service has not yet delievered the inventory
+ /// for this user then the request will be queued.
///
+ ///
///
///
public bool MoveFolder(LLUUID folderID, LLUUID parentID)
@@ -470,7 +482,11 @@ 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(LLUUID folderID)
{
@@ -540,23 +556,46 @@ namespace OpenSim.Framework.Communications.Cache
///
/// Delete an item from the user's inventory
+ ///
+ /// If the inventory service has not yet delievered the inventory
+ /// for this user then the request will be queued.
///
- ///
- ///
- ///
- public bool DeleteItem(InventoryItemBase item)
+ ///
+ ///
+ /// true on a successful delete or a if the request is queued.
+ /// Returns false on an immediate failure
+ ///
+ public bool DeleteItem(LLUUID itemID)
{
- bool result = false;
if (HasInventory)
{
- result = RootFolder.DeleteItem(item.ID);
- if (result)
+ // XXX For historical reasons (grid comms), we need to retrieve the whole item in order to delete, even though
+ // really only the item id is required.
+ InventoryItemBase item = RootFolder.FindItem(itemID);
+
+ if (null == item)
{
- m_commsManager.InventoryService.DeleteItem(item);
+ m_log.WarnFormat("[AGENT INVENTORY]: Tried to delete item {0} which does not exist", itemID);
+
+ return false;
+ }
+
+ if (RootFolder.DeleteItem(item.ID))
+ {
+ return m_commsManager.InventoryService.DeleteItem(item);
}
}
+ else
+ {
+ AddRequest(
+ new InventoryRequest(
+ Delegate.CreateDelegate(typeof(DeleteItemDelegate), this, "DeleteItem"),
+ new object[] { itemID }));
+
+ return true;
+ }
- return result;
+ return false;
}
}
diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
index 39296eb9d8..af05af3b23 100644
--- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
+++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
@@ -163,6 +163,7 @@ namespace OpenSim.Framework.Communications.Cache
}
}
}
+
return found;
}
diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs
index 4864185dde..5c1902fa57 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(18000);
+ Thread.Sleep(18000);
InventoryCollection invCollection = new InventoryCollection();
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 7cce216369..490457de4a 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -467,6 +467,14 @@ namespace OpenSim.Region.Environment.Scenes
return asset;
}
+ ///
+ /// Move an item within the agent's inventory.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public void MoveInventoryItem(IClientAPI remoteClient, LLUUID folderID, LLUUID itemID, int length,
string newName)
{
@@ -474,6 +482,7 @@ namespace OpenSim.Region.Environment.Scenes
"[AGENT INVENTORY]: Moving item {0} to {1} for {2}", itemID, folderID, remoteClient.AgentId);
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
+
if (userInfo == null)
{
m_log.Error("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId.ToString());
@@ -491,7 +500,8 @@ namespace OpenSim.Region.Environment.Scenes
item.Name = newName;
}
item.Folder = folderID;
- userInfo.DeleteItem(item);
+
+ userInfo.DeleteItem(item.ID);
// TODO: preserve current permissions?
AddInventoryItem(remoteClient, item);
@@ -616,6 +626,11 @@ namespace OpenSim.Region.Environment.Scenes
}
}
+ ///
+ /// Remove an inventory item for the client's inventory
+ ///
+ ///
+ ///
private void RemoveInventoryItem(IClientAPI remoteClient, LLUUID itemID)
{
CachedUserInfo userInfo
@@ -623,26 +638,14 @@ namespace OpenSim.Region.Environment.Scenes
if (userInfo == null)
{
- m_log.ErrorFormat(
- "[AGENT INVENTORY]: Failed to find user {0} {1} to remove inventory item {2}",
+ m_log.WarnFormat(
+ "[AGENT INVENTORY]: Failed to find user {0} {1} to delete inventory item {2}",
remoteClient.Name, remoteClient.AgentId, itemID);
return;
}
- // is going through the root folder really the best way?
- // this triggers a tree walk to find and remove the item. 8-(
- // since this only happens in Trash (in theory) shouldn't we grab
- // the trash folder directly instead of RootFolder?
- if (userInfo.RootFolder != null)
- {
- InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
-
- if (item != null)
- {
- userInfo.DeleteItem(item);
- }
- }
+ userInfo.DeleteItem(itemID);
}
///
@@ -658,7 +661,7 @@ namespace OpenSim.Region.Environment.Scenes
if (userInfo == null)
{
- m_log.Error("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId.ToString());
+ m_log.Warn("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId.ToString());
return;
}