From fa9a4a9a2b145fed271001f3836df9cef8103e5e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 9 Jul 2016 00:20:51 +0100 Subject: some changes to RequestInventoryFile() --- .../Framework/Scenes/SceneObjectPartInventory.cs | 74 +++++++++++----------- 1 file changed, 36 insertions(+), 38 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 3b029f2..5b64aac 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -48,6 +48,8 @@ namespace OpenSim.Region.Framework.Scenes private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private byte[] m_inventoryFileData = new byte[0]; + private byte[] m_inventoryFileNameBytes = new byte[0]; + private string m_inventoryFileName = ""; private uint m_inventoryFileNameSerial = 0; private bool m_inventoryPrivileged = false; private object m_inventoryFileLock = new object(); @@ -1112,28 +1114,9 @@ namespace OpenSim.Region.Framework.Scenes /// public void RequestInventoryFile(IClientAPI client, IXfer xferManager) { - lock (m_inventoryFileLock) { - string filename = "inventory_" + UUID.Random().ToString() + ".tmp"; - bool changed = false; - if (m_inventoryFileNameSerial < m_inventorySerial) - { - m_inventoryFileNameSerial = m_inventorySerial; - changed = true; - } - - if (m_inventoryFileData.Length < 2) - changed = true; - - bool includeAssets = false; - if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) - includeAssets = true; - - if (m_inventoryPrivileged != includeAssets) - changed = true; - Items.LockItemsForRead(true); @@ -1141,7 +1124,6 @@ namespace OpenSim.Region.Framework.Scenes { Items.LockItemsForRead(false); client.SendTaskInventory(m_part.UUID, 0, new byte[0]); - return; } @@ -1152,14 +1134,29 @@ namespace OpenSim.Region.Framework.Scenes return; } - if (!changed) + if (m_inventoryFileNameSerial != m_inventorySerial) { - Items.LockItemsForRead(false); + m_inventoryFileNameSerial = m_inventorySerial; + changed = true; + } + + Items.LockItemsForRead(false); + + if (m_inventoryFileData.Length < 2) + changed = true; - xferManager.AddNewFile(filename, - m_inventoryFileData); + bool includeAssets = false; + if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) + includeAssets = true; + + if (m_inventoryPrivileged != includeAssets) + changed = true; + + if (!changed) + { + xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial, - Util.StringToBytes256(filename)); + m_inventoryFileNameBytes); return; } @@ -1168,6 +1165,8 @@ namespace OpenSim.Region.Framework.Scenes InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); + Items.LockItemsForRead(true); + foreach (TaskInventoryItem item in m_items.Values) { UUID ownerID = item.OwnerID; @@ -1222,9 +1221,10 @@ namespace OpenSim.Region.Framework.Scenes if (m_inventoryFileData.Length > 2) { - xferManager.AddNewFile(filename, m_inventoryFileData); - client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial, - Util.StringToBytes256(filename)); + m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; + m_inventoryFileNameBytes = Util.StringToBytes256(m_inventoryFileName); + xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); + client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial,m_inventoryFileNameBytes); return; } @@ -1267,26 +1267,22 @@ namespace OpenSim.Region.Framework.Scenes AddNameValueLine("obj_id", folderID.ToString()); AddNameValueLine("parent_id", parentID.ToString()); AddNameValueLine("type", "category"); - AddNameValueLine("name", "Contents|"); - AddSectionEnd(); + AddNameValueLine("name", "Contents|\n\t}"); } public void AddItemStart() { - BuildString.Append("\tinv_item\t0\n"); - AddSectionStart(); + BuildString.Append("\tinv_item\t0\n\t{\n"); } public void AddPermissionsStart() { - BuildString.Append("\tpermissions 0\n"); - AddSectionStart(); + BuildString.Append("\tpermissions 0\n\t{\n"); } public void AddSaleStart() { - BuildString.Append("\tsale_info\t0\n"); - AddSectionStart(); + BuildString.Append("\tsale_info\t0\n\t{\n"); } protected void AddSectionStart() @@ -1307,8 +1303,10 @@ namespace OpenSim.Region.Framework.Scenes public void AddNameValueLine(string name, string value) { BuildString.Append("\t\t"); - BuildString.Append(name + "\t"); - BuildString.Append(value + "\n"); + BuildString.Append(name); + BuildString.Append("\t"); + BuildString.Append(value); + BuildString.Append("\n"); } public String GetString() -- cgit v1.1