From eaefae7e20c95266ad84ea59912cf8c011ccd1b5 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 17 Jul 2016 22:52:58 +0100 Subject: [PATCH] don't loose inventory items when there are bad folders --- .../FetchInventory/FetchInvDescHandler.cs | 98 ++++++++----------- .../Linden/Caps/WebFetchInvDescModule.cs | 12 +-- 2 files changed, 49 insertions(+), 61 deletions(-) diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs index e3a9a2213b..45eda5735d 100644 --- a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs +++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs @@ -30,6 +30,7 @@ using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; +using System.Text; using log4net; using Nini.Config; using OpenMetaverse; @@ -93,8 +94,8 @@ namespace OpenSim.Capabilities.Handlers ArrayList foldersrequested = (ArrayList)hash["folders"]; - string response = ""; - string bad_folders_response = ""; + StringBuilder tmpresponse = new StringBuilder(1024); + StringBuilder tmpbadfolders = new StringBuilder(1024); List folders = new List(); for (int i = 0; i < foldersrequested.Count; i++) @@ -142,43 +143,38 @@ namespace OpenSim.Capabilities.Handlers inventoryitemstr = inventoryitemstr.Replace("folders", ""); inventoryitemstr = inventoryitemstr.Replace("", ""); - response += inventoryitemstr; + tmpresponse.Append(inventoryitemstr); } //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Bad folders {0}", string.Join(", ", bad_folders)); foreach (UUID bad in bad_folders) - bad_folders_response += "" + bad + ""; + { + tmpbadfolders.Append("folder_id"); + tmpbadfolders.Append(bad.ToString()); + tmpbadfolders.Append("errorUnknown"); + } } - if (response.Length == 0) + StringBuilder lastresponse = new StringBuilder(1024); + lastresponse.Append(""); + if(tmpresponse.Length > 0) { - /* Viewers expect a bad_folders array when not available */ - if (bad_folders_response.Length != 0) - { - response = "bad_folders" + bad_folders_response + ""; - } - else - { - response = "folders"; - } + lastresponse.Append("folders"); + lastresponse.Append(tmpresponse.ToString()); + lastresponse.Append(""); } else + lastresponse.Append("folders"); + + if(tmpbadfolders.Length > 0) { - if (bad_folders_response.Length != 0) - { - response = "folders" + response + "bad_folders" + bad_folders_response + ""; - } - else - { - response = "folders" + response + ""; - } + lastresponse.Append("bad_folders"); + lastresponse.Append(tmpbadfolders.ToString()); + lastresponse.Append(""); } + lastresponse.Append(""); - //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Replying to CAPS fetch inventory request for {0} folders. Item count {1}", folders.Count, item_count); - //m_log.Debug("[WEB FETCH INV DESC HANDLER] " + response); - - return response; - + return lastresponse.ToString(); } /// @@ -285,8 +281,8 @@ namespace OpenSim.Capabilities.Handlers { //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Received request for {0} folders", foldersrequested.Count); - string response = ""; - string bad_folders_response = ""; + StringBuilder tmpresponse = new StringBuilder(1024); + StringBuilder tmpbadfolders = new StringBuilder(1024); for (int i = 0; i < foldersrequested.Count; i++) { @@ -308,7 +304,9 @@ namespace OpenSim.Capabilities.Handlers if (null == reply) { - bad_folders_response += "" + llsdRequest.folder_id.ToString() + ""; + tmpbadfolders.Append("folder_id"); + tmpbadfolders.Append(llsdRequest.folder_id.ToString()); + tmpbadfolders.Append("errorUnknown"); } else { @@ -317,39 +315,29 @@ namespace OpenSim.Capabilities.Handlers inventoryitemstr = inventoryitemstr.Replace("", ""); } - response += inventoryitemstr; + tmpresponse.Append(inventoryitemstr); } - if (response.Length == 0) + StringBuilder lastresponse = new StringBuilder(1024); + lastresponse.Append(""); + if(tmpresponse.Length > 0) { - /* Viewers expect a bad_folders array when not available */ - if (bad_folders_response.Length != 0) - { - response = "bad_folders" + bad_folders_response + ""; - } - else - { - response = "folders"; - } + lastresponse.Append("folders"); + lastresponse.Append(tmpresponse.ToString()); + lastresponse.Append(""); } else + lastresponse.Append("folders"); + + if(tmpbadfolders.Length > 0) { - if (bad_folders_response.Length != 0) - { - response = "folders" + response + "bad_folders" + bad_folders_response + ""; - } - else - { - response = "folders" + response + ""; - } + lastresponse.Append("bad_folders"); + lastresponse.Append(tmpbadfolders.ToString()); + lastresponse.Append(""); } + lastresponse.Append(""); - // m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Replying to CAPS fetch inventory request"); - //m_log.Debug("[WEB FETCH INV DESC HANDLER] "+response); - - return response; - - // } + return lastresponse.ToString(); } /// diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index ed5b3ddd1f..0277a24e5a 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs @@ -61,7 +61,6 @@ namespace OpenSim.Region.ClientStack.Linden public UUID reqID; public Hashtable request; public ScenePresence presence; - public List folders; } private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -296,8 +295,10 @@ namespace OpenSim.Region.ClientStack.Linden reqinfo.reqID = x; reqinfo.request = y; reqinfo.presence = sp; - reqinfo.folders = new List(); +/* why where we doing this? just to get cof ? + List folders = new List(); + // Decode the request here string request = y["body"].ToString(); @@ -333,11 +334,11 @@ namespace OpenSim.Region.ClientStack.Linden UUID folderID; if (UUID.TryParse(folder, out folderID)) { - if (!reqinfo.folders.Contains(folderID)) + if (!folders.Contains(folderID)) { if (sp.COF != UUID.Zero && sp.COF == folderID) highPriority = true; - reqinfo.folders.Add(folderID); + folders.Add(folderID); } } } @@ -345,6 +346,7 @@ namespace OpenSim.Region.ClientStack.Linden if (highPriority) m_queue.PriorityEnqueue(reqinfo); else +*/ m_queue.Enqueue(reqinfo); }; @@ -406,7 +408,6 @@ namespace OpenSim.Region.ClientStack.Linden if(dropedResponses.Contains(requestID)) { dropedResponses.Remove(requestID); - requestinfo.folders.Clear(); requestinfo.request.Clear(); WebFetchInvDescModule.ProcessedRequestsCount++; return; @@ -417,7 +418,6 @@ namespace OpenSim.Region.ClientStack.Linden m_log.WarnFormat("[FETCH INVENTORY DESCENDENTS2 MODULE]: Caught in the act of loosing responses! Please report this on mantis #7054"); responses[requestID] = response; } - requestinfo.folders.Clear(); requestinfo.request.Clear(); WebFetchInvDescModule.ProcessedRequestsCount++; }