From 7acc3096f49a2ae265e54ee6e83c1901cb879f84 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 23 Apr 2022 04:04:43 +0100 Subject: [PATCH] now the first section of Libraries.xml should only contain entry RootVersion to define the Opensim library version. THis should eb incremented when there are changes on ny library entry --- .../InventoryService/LibraryService.cs | 51 +++++++++---------- bin/inventory/Libraries.xml | 24 --------- .../ScriptsLibrary/ScriptsLibraryFolders.xml | 4 +- bin/inventory/SettingsLibrary/Folders.xml | 4 +- 4 files changed, 28 insertions(+), 55 deletions(-) diff --git a/OpenSim/Services/InventoryService/LibraryService.cs b/OpenSim/Services/InventoryService/LibraryService.cs index 8b3ee400db..f2ddce5956 100644 --- a/OpenSim/Services/InventoryService/LibraryService.cs +++ b/OpenSim/Services/InventoryService/LibraryService.cs @@ -50,6 +50,10 @@ namespace OpenSim.Services.InventoryService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly UUID libOwner = Constants.m_MrOpenSimID; + private const string m_LibraryRootFolderIDstr = "00000112-000f-0000-0000-000100bba000"; + private static readonly UUID m_LibraryRootFolderID = new UUID(m_LibraryRootFolderIDstr); + static private InventoryFolderImpl m_LibraryRootFolder; public InventoryFolderImpl LibraryRootFolder @@ -57,7 +61,6 @@ namespace OpenSim.Services.InventoryService get { return m_LibraryRootFolder; } } - static private UUID libOwner = new UUID("11111111-1111-0000-0000-000100bba000"); /// /// Holds the root library folder and all its descendents. This is really only used during inventory @@ -98,12 +101,11 @@ namespace OpenSim.Services.InventoryService m_LibraryRootFolder = new InventoryFolderImpl(); m_LibraryRootFolder.Owner = libOwner; - m_LibraryRootFolder.ID = new UUID("00000112-000f-0000-0000-000100bba000"); + m_LibraryRootFolder.ID = m_LibraryRootFolderID; m_LibraryRootFolder.Name = pLibName; m_LibraryRootFolder.ParentID = UUID.Zero; m_LibraryRootFolder.Type = 8; m_LibraryRootFolder.Version = 1; - libraryFolders.Add(m_LibraryRootFolder.ID, m_LibraryRootFolder); LoadLibraries(pLibrariesLocation); @@ -148,17 +150,16 @@ namespace OpenSim.Services.InventoryService protected void ReadLibraryFromConfig(IConfig config, string path) { string basePath = Path.GetDirectoryName(path); - m_LibraryRootFolder.Version = (ushort)config.GetInt("RootVersion", m_LibraryRootFolder.Version); - string foldersPath - = Path.Combine( - basePath, config.GetString("foldersFile", String.Empty)); + if (config.Contains("RootVersion")) + { + m_LibraryRootFolder.Version = (ushort)config.GetInt("RootVersion", m_LibraryRootFolder.Version); + return; + } + string foldersPath = Path.Combine(basePath, config.GetString("foldersFile", String.Empty)); LoadFromFile(foldersPath, "Library folders", ReadFolderFromConfig); - string itemsPath - = Path.Combine( - basePath, config.GetString("itemsFile", String.Empty)); - + string itemsPath = Path.Combine( basePath, config.GetString("itemsFile", String.Empty)); LoadFromFile(itemsPath, "Library items", ReadItemFromConfig); } @@ -170,21 +171,18 @@ namespace OpenSim.Services.InventoryService { InventoryFolderImpl folderInfo = new InventoryFolderImpl(); - folderInfo.ID = new UUID(config.GetString("folderID", m_LibraryRootFolder.ID.ToString())); + folderInfo.ID = new UUID(config.GetString("folderID", m_LibraryRootFolderIDstr)); folderInfo.Name = config.GetString("name", "unknown"); - folderInfo.ParentID = new UUID(config.GetString("parentFolderID", m_LibraryRootFolder.ID.ToString())); + folderInfo.ParentID = new UUID(config.GetString("parentFolderID", m_LibraryRootFolderIDstr)); folderInfo.Type = (short)config.GetInt("type", 8); folderInfo.Version = (ushort)config.GetInt("version", 1); folderInfo.Owner = libOwner; - if (libraryFolders.ContainsKey(folderInfo.ParentID)) + if (libraryFolders.TryGetValue(folderInfo.ParentID, out InventoryFolderImpl parentFolder)) { - InventoryFolderImpl parentFolder = libraryFolders[folderInfo.ParentID]; - libraryFolders.Add(folderInfo.ID, folderInfo); parentFolder.AddChildFolder(folderInfo); - -// m_log.InfoFormat("[LIBRARY INVENTORY]: Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID); + //m_log.InfoFormat("[LIBRARY INVENTORY]: Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID); } else { @@ -203,10 +201,10 @@ namespace OpenSim.Services.InventoryService InventoryItemBase item = new InventoryItemBase(); item.Owner = libOwner; item.CreatorId = libOwner.ToString(); - UUID itID = new UUID(config.GetString("inventoryID", m_LibraryRootFolder.ID.ToString())); + UUID itID = new UUID(config.GetString("inventoryID", m_LibraryRootFolderIDstr)); item.ID = itID; item.AssetID = new UUID(config.GetString("assetID", item.ID.ToString())); - item.Folder = new UUID(config.GetString("folderID", m_LibraryRootFolder.ID.ToString())); + item.Folder = new UUID(config.GetString("folderID", m_LibraryRootFolderIDstr)); item.Name = config.GetString("name", String.Empty); item.Description = config.GetString("description", item.Name); item.InvType = config.GetInt("inventoryType", 0); @@ -218,9 +216,8 @@ namespace OpenSim.Services.InventoryService item.GroupPermissions = (uint)config.GetLong("basePermissions", m_GroupPermissions);; item.Flags = (uint)config.GetInt("flags", 0); - if (libraryFolders.ContainsKey(item.Folder)) + if (libraryFolders.TryGetValue(item.Folder, out InventoryFolderImpl parentFolder)) { - InventoryFolderImpl parentFolder = libraryFolders[item.Folder]; if(!parentFolder.Items.ContainsKey(itID)) { parentFolder.Items.Add(itID, item); @@ -279,7 +276,7 @@ namespace OpenSim.Services.InventoryService public Dictionary GetAllFolders() { Dictionary fs = new Dictionary(); - fs.Add(m_LibraryRootFolder.ID, m_LibraryRootFolder); + fs.Add(m_LibraryRootFolderID, m_LibraryRootFolder); List fis = TraverseFolder(m_LibraryRootFolder); foreach (InventoryFolderImpl f in fis) { @@ -302,8 +299,8 @@ namespace OpenSim.Services.InventoryService public InventoryItemBase GetItem(UUID itemID) { - if(m_items.ContainsKey(itemID)) - return m_items[itemID]; + if(m_items.TryGetValue(itemID, out InventoryItemBase it)) + return it; return null; } @@ -312,8 +309,8 @@ namespace OpenSim.Services.InventoryService List items = new List(); foreach (UUID id in ids) { - if(m_items.ContainsKey(id)) - items.Add(m_items[id]); + if (m_items.TryGetValue(id, out InventoryItemBase it)) + items.Add(it); } if(items.Count == 0) diff --git a/bin/inventory/Libraries.xml b/bin/inventory/Libraries.xml index 818565e0ca..98b19e9bfa 100644 --- a/bin/inventory/Libraries.xml +++ b/bin/inventory/Libraries.xml @@ -14,69 +14,46 @@ --> - - -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
@@ -85,5 +62,4 @@
- diff --git a/bin/inventory/ScriptsLibrary/ScriptsLibraryFolders.xml b/bin/inventory/ScriptsLibrary/ScriptsLibraryFolders.xml index c2a7832f0b..b9c18beebd 100644 --- a/bin/inventory/ScriptsLibrary/ScriptsLibraryFolders.xml +++ b/bin/inventory/ScriptsLibrary/ScriptsLibraryFolders.xml @@ -21,12 +21,12 @@ - +
- +
diff --git a/bin/inventory/SettingsLibrary/Folders.xml b/bin/inventory/SettingsLibrary/Folders.xml index f1665561b4..97e0228aeb 100644 --- a/bin/inventory/SettingsLibrary/Folders.xml +++ b/bin/inventory/SettingsLibrary/Folders.xml @@ -3,8 +3,8 @@ - - + +