From 4fcf76eb0b780a2d1d5b8509e04514f0af0a63c9 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 bb24292bf2..79afc8d2a5 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs @@ -308,6 +308,8 @@ namespace OpenSim.Services.InventoryService // foreach (UUID id in folderIDs) { + if (!ParentIsTrash(id)) + continue; InventoryFolderBase f = new InventoryFolderBase(); f.ID = id; PurgeFolder(f); @@ -319,6 +321,9 @@ namespace OpenSim.Services.InventoryService public virtual bool PurgeFolder(InventoryFolderBase folder) { + if (!ParentIsTrash(folder.ID)) + return false; + XInventoryFolder[] subFolders = m_Database.GetFolders( new string[] { "parentFolderID" }, new string[] { folder.ID.ToString() }); @@ -519,5 +524,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; + } } }