From 8de65a8fb360f9ab99a609311dfb56e15a9de76c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 1 Jun 2015 20:05:51 -0700 Subject: Mantis #7594: putting things as they were before regarding duplicate removal. Also added test to check that duplicates are being removed. The test passes. I have no idea how duplicates would not be removed, as reported in the mantis. --- .../Handlers/FetchInventory/FetchInvDescHandler.cs | 7 ++-- .../FetchInventoryDescendents2HandlerTests.cs | 39 ++++++++++++++++++++++ 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs index 0c83b26..4798dc2 100644 --- a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs +++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs @@ -111,10 +111,9 @@ namespace OpenSim.Capabilities.Handlers } // Filter duplicate folder ids that bad viewers may send - var unique = folders.GroupBy(f => f.folder_id).Select(n => n.First()); - folders.Clear(); - foreach (var f in unique) - folders.Add(f); + if (folders.Find(f => f.folder_id == llsdRequest.folder_id) == null) + folders.Add(llsdRequest); + } if (folders.Count > 0) diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs b/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs index d34423d..056b4db 100644 --- a/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs +++ b/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Net; +using System.Text.RegularExpressions; using log4net; using log4net.Config; using NUnit.Framework; @@ -223,6 +224,44 @@ namespace OpenSim.Capabilities.Handlers.FetchInventory.Tests pos2 = llsdresponse.IndexOf("Link to Objects folder"); Assert.Less(pos1, pos2, "Contents of source of folder link is after folder link"); } + + [Test] + public void Test_004_DuplicateFolders() + { + TestHelpers.InMethod(); + + FetchInvDescHandler handler = new FetchInvDescHandler(m_scene.InventoryService, null); + TestOSHttpRequest req = new TestOSHttpRequest(); + TestOSHttpResponse resp = new TestOSHttpResponse(); + + string request = "folders"; + request += "fetch_folders1fetch_items1folder_id"; + request += m_rootFolderID; + request += "owner_id00000000-0000-0000-0000-000000000000sort_order1"; + request += "fetch_folders1fetch_items1folder_id"; + request += m_notecardsFolder; + request += "owner_id00000000-0000-0000-0000-000000000000sort_order1"; + request += "fetch_folders1fetch_items1folder_id"; + request += m_rootFolderID; + request += "owner_id00000000-0000-0000-0000-000000000000sort_order1"; + request += "fetch_folders1fetch_items1folder_id"; + request += m_notecardsFolder; + request += "owner_id00000000-0000-0000-0000-000000000000sort_order1"; + request += ""; + + string llsdresponse = handler.FetchInventoryDescendentsRequest(request, "/FETCH", string.Empty, req, resp); + Console.WriteLine(llsdresponse); + + string root_folder = "folder_id" + m_rootFolderID + ""; + string notecards_folder = "folder_id" + m_notecardsFolder + ""; + + Assert.That(llsdresponse.Contains(root_folder), "Missing root folder"); + Assert.That(llsdresponse.Contains(notecards_folder), "Missing notecards folder"); + int count = Regex.Matches(llsdresponse, root_folder).Count; + Assert.AreEqual(1, count, "More than 1 root folder in response"); + count = Regex.Matches(llsdresponse, notecards_folder).Count; + Assert.AreEqual(2, count, "More than 1 notecards folder in response"); // Notecards will also be under root, so 2 + } } } \ No newline at end of file -- cgit v1.1