diff options
author | Justin Clark-Casey (justincc) | 2010-08-27 23:22:49 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-08-27 23:22:49 +0100 |
commit | 86937d0a0f5572b002cdb6efc499c234b2a9bd1b (patch) | |
tree | 6791667725972cfbc4a7965326f83502c53b87bf /OpenSim | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-86937d0a0f5572b002cdb6efc499c234b2a9bd1b.zip opensim-SC-86937d0a0f5572b002cdb6efc499c234b2a9bd1b.tar.gz opensim-SC-86937d0a0f5572b002cdb6efc499c234b2a9bd1b.tar.bz2 opensim-SC-86937d0a0f5572b002cdb6efc499c234b2a9bd1b.tar.xz |
allow inventory path specified in "load iar" to start with a / (e.g. /Objects is now valid where it wasn't before)
Diffstat (limited to 'OpenSim')
3 files changed, 45 insertions, 13 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs index 84afb40..8343091 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs | |||
@@ -41,7 +41,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
41 | /// </summary> | 41 | /// </summary> |
42 | public static class InventoryArchiveUtils | 42 | public static class InventoryArchiveUtils |
43 | { | 43 | { |
44 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 45 | ||
46 | // Character used for escaping the path delimter ("\/") and itself ("\\") in human escaped strings | 46 | // Character used for escaping the path delimter ("\/") and itself ("\\") in human escaped strings |
47 | public static readonly char ESCAPE_CHARACTER = '\\'; | 47 | public static readonly char ESCAPE_CHARACTER = '\\'; |
@@ -120,6 +120,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
120 | foundFolders.Add(startFolder); | 120 | foundFolders.Add(startFolder); |
121 | return foundFolders; | 121 | return foundFolders; |
122 | } | 122 | } |
123 | |||
124 | // If the path isn't just / then trim any starting extraneous slashes | ||
125 | path = path.TrimStart(new char[] { PATH_DELIMITER }); | ||
126 | |||
127 | // m_log.DebugFormat("[INVENTORY ARCHIVE UTILS]: Adjusted path in FindFolderByPath() is [{0}]", path); | ||
123 | 128 | ||
124 | string[] components = SplitEscapedPath(path); | 129 | string[] components = SplitEscapedPath(path); |
125 | components[0] = UnescapePath(components[0]); | 130 | components[0] = UnescapePath(components[0]); |
@@ -199,6 +204,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
199 | public static InventoryItemBase FindItemByPath( | 204 | public static InventoryItemBase FindItemByPath( |
200 | IInventoryService inventoryService, InventoryFolderBase startFolder, string path) | 205 | IInventoryService inventoryService, InventoryFolderBase startFolder, string path) |
201 | { | 206 | { |
207 | // If the path isn't just / then trim any starting extraneous slashes | ||
208 | path = path.TrimStart(new char[] { PATH_DELIMITER }); | ||
209 | |||
202 | string[] components = SplitEscapedPath(path); | 210 | string[] components = SplitEscapedPath(path); |
203 | components[0] = UnescapePath(components[0]); | 211 | components[0] = UnescapePath(components[0]); |
204 | 212 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 892680e..e8a26b5 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -343,6 +343,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
343 | } | 343 | } |
344 | 344 | ||
345 | /// <summary> | 345 | /// <summary> |
346 | /// Test that things work when the load path specified starts with a slash | ||
347 | /// </summary> | ||
348 | [Test] | ||
349 | public void TestLoadIarPathStartsWithSlash() | ||
350 | { | ||
351 | TestHelper.InMethod(); | ||
352 | log4net.Config.XmlConfigurator.Configure(); | ||
353 | |||
354 | SerialiserModule serialiserModule = new SerialiserModule(); | ||
355 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); | ||
356 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
357 | SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | ||
358 | |||
359 | UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "password"); | ||
360 | archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/Objects", "password", m_iarStream); | ||
361 | |||
362 | InventoryItemBase foundItem1 | ||
363 | = InventoryArchiveUtils.FindItemByPath( | ||
364 | scene.InventoryService, m_ua1.PrincipalID, "/Objects/" + m_item1Name); | ||
365 | |||
366 | Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1 in TestLoadIarFolderStartsWithSlash()"); | ||
367 | } | ||
368 | |||
369 | /// <summary> | ||
346 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where | 370 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where |
347 | /// an account exists with the creator name. | 371 | /// an account exists with the creator name. |
348 | /// </summary> | 372 | /// </summary> |
diff --git a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs index ed0b1a6..b70b47d 100644 --- a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs | |||
@@ -86,7 +86,7 @@ namespace OpenSim.Tests.Common.Mock | |||
86 | { | 86 | { |
87 | InventoryFolderBase folder = m_folders[folderID]; | 87 | InventoryFolderBase folder = m_folders[folderID]; |
88 | 88 | ||
89 | m_log.DebugFormat("[MOCK INV DB]: Getting items in folder {0} {1}", folder.Name, folder.ID); | 89 | // m_log.DebugFormat("[MOCK INV DB]: Getting items in folder {0} {1}", folder.Name, folder.ID); |
90 | 90 | ||
91 | List<InventoryItemBase> items = new List<InventoryItemBase>(); | 91 | List<InventoryItemBase> items = new List<InventoryItemBase>(); |
92 | 92 | ||
@@ -94,7 +94,7 @@ namespace OpenSim.Tests.Common.Mock | |||
94 | { | 94 | { |
95 | if (item.Folder == folderID) | 95 | if (item.Folder == folderID) |
96 | { | 96 | { |
97 | m_log.DebugFormat("[MOCK INV DB]: getInventoryInFolder() adding item {0}", item.Name); | 97 | // m_log.DebugFormat("[MOCK INV DB]: getInventoryInFolder() adding item {0}", item.Name); |
98 | items.Add(item); | 98 | items.Add(item); |
99 | } | 99 | } |
100 | } | 100 | } |
@@ -106,7 +106,7 @@ namespace OpenSim.Tests.Common.Mock | |||
106 | 106 | ||
107 | public InventoryFolderBase getUserRootFolder(UUID user) | 107 | public InventoryFolderBase getUserRootFolder(UUID user) |
108 | { | 108 | { |
109 | m_log.DebugFormat("[MOCK INV DB]: Looking for root folder for {0}", user); | 109 | // m_log.DebugFormat("[MOCK INV DB]: Looking for root folder for {0}", user); |
110 | 110 | ||
111 | InventoryFolderBase folder = null; | 111 | InventoryFolderBase folder = null; |
112 | m_rootFolders.TryGetValue(user, out folder); | 112 | m_rootFolders.TryGetValue(user, out folder); |
@@ -118,7 +118,7 @@ namespace OpenSim.Tests.Common.Mock | |||
118 | { | 118 | { |
119 | InventoryFolderBase parentFolder = m_folders[parentID]; | 119 | InventoryFolderBase parentFolder = m_folders[parentID]; |
120 | 120 | ||
121 | m_log.DebugFormat("[MOCK INV DB]: Getting folders in folder {0} {1}", parentFolder.Name, parentFolder.ID); | 121 | // m_log.DebugFormat("[MOCK INV DB]: Getting folders in folder {0} {1}", parentFolder.Name, parentFolder.ID); |
122 | 122 | ||
123 | List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); | 123 | List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); |
124 | 124 | ||
@@ -126,9 +126,9 @@ namespace OpenSim.Tests.Common.Mock | |||
126 | { | 126 | { |
127 | if (folder.ParentID == parentID) | 127 | if (folder.ParentID == parentID) |
128 | { | 128 | { |
129 | m_log.DebugFormat( | 129 | // m_log.DebugFormat( |
130 | "[MOCK INV DB]: Found folder {0} {1} in {2} {3}", | 130 | // "[MOCK INV DB]: Found folder {0} {1} in {2} {3}", |
131 | folder.Name, folder.ID, parentFolder.Name, parentFolder.ID); | 131 | // folder.Name, folder.ID, parentFolder.Name, parentFolder.ID); |
132 | 132 | ||
133 | folders.Add(folder); | 133 | folders.Add(folder); |
134 | } | 134 | } |
@@ -152,9 +152,9 @@ namespace OpenSim.Tests.Common.Mock | |||
152 | 152 | ||
153 | public void addInventoryFolder(InventoryFolderBase folder) | 153 | public void addInventoryFolder(InventoryFolderBase folder) |
154 | { | 154 | { |
155 | m_log.DebugFormat( | 155 | // m_log.DebugFormat( |
156 | "[MOCK INV DB]: Adding inventory folder {0} {1} type {2}", | 156 | // "[MOCK INV DB]: Adding inventory folder {0} {1} type {2}", |
157 | folder.Name, folder.ID, (AssetType)folder.Type); | 157 | // folder.Name, folder.ID, (AssetType)folder.Type); |
158 | 158 | ||
159 | m_folders[folder.ID] = folder; | 159 | m_folders[folder.ID] = folder; |
160 | 160 | ||
@@ -187,8 +187,8 @@ namespace OpenSim.Tests.Common.Mock | |||
187 | { | 187 | { |
188 | InventoryFolderBase folder = m_folders[item.Folder]; | 188 | InventoryFolderBase folder = m_folders[item.Folder]; |
189 | 189 | ||
190 | m_log.DebugFormat( | 190 | // m_log.DebugFormat( |
191 | "[MOCK INV DB]: Adding inventory item {0} {1} in {2} {3}", item.Name, item.ID, folder.Name, folder.ID); | 191 | // "[MOCK INV DB]: Adding inventory item {0} {1} in {2} {3}", item.Name, item.ID, folder.Name, folder.ID); |
192 | 192 | ||
193 | m_items[item.ID] = item; | 193 | m_items[item.ID] = item; |
194 | } | 194 | } |