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; + } } }