From 95230bee6d7fbcc2edd358d15b0c433857efcb83 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 24 Jul 2010 23:15:06 +0100 Subject: [PATCH] Fix some inventory issues --- .../InventoryService/XInventoryService.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index 2c79c777f8..312c595449 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs @@ -299,6 +299,8 @@ namespace OpenSim.Services.InventoryService // foreach (UUID id in folderIDs) { + if (!ParentIsTrash(id)) + continue; InventoryFolderBase f = new InventoryFolderBase(); f.ID = id; PurgeFolder(f); @@ -310,6 +312,9 @@ namespace OpenSim.Services.InventoryService public bool PurgeFolder(InventoryFolderBase folder) { + if (!ParentIsTrash(folder.ID)) + return false; + XInventoryFolder[] subFolders = m_Database.GetFolders( new string[] { "parentFolderID" }, new string[] { folder.ID.ToString() }); @@ -504,5 +509,29 @@ namespace OpenSim.Services.InventoryService return newItem; } + + private bool ParentIsTrash(UUID folderID) + { + XInventoryFolder[] folder = m_Database.GetFolders(new string[] {"folderID"}, new string[] {folderID.ToString()}); + if (folder.Length < 1) + return false; + + UUID parentFolder = folder[0].parentFolderID; + + while (parentFolder != UUID.Zero) + { + XInventoryFolder[] parent = m_Database.GetFolders(new string[] {"folderID"}, new string[] {parentFolder.ToString()}); + if (parent.Length < 1) + return false; + + if (parent[0].type == (int)AssetType.TrashFolder) + return true; + if (parent[0].type == (int)AssetType.RootFolder) + return false; + + parentFolder = parent[0].parentFolderID; + } + return false; + } } }