diff options
5 files changed, 129 insertions, 84 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index b4f1ed6..9996074 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -100,18 +100,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
100 | 100 | ||
101 | List<InventoryNodeBase> loadedNodes = new List<InventoryNodeBase>(); | 101 | List<InventoryNodeBase> loadedNodes = new List<InventoryNodeBase>(); |
102 | 102 | ||
103 | InventoryFolderBase rootDestinationFolder | 103 | List<InventoryFolderBase> folderCandidates |
104 | = InventoryArchiveUtils.FindFolderByPath( | 104 | = InventoryArchiveUtils.FindFolderByPath( |
105 | m_scene.InventoryService, m_userInfo.PrincipalID, m_invPath); | 105 | m_scene.InventoryService, m_userInfo.PrincipalID, m_invPath); |
106 | 106 | ||
107 | if (null == rootDestinationFolder) | 107 | if (folderCandidates.Count == 0) |
108 | { | 108 | { |
109 | // Possibly provide an option later on to automatically create this folder if it does not exist | 109 | // Possibly provide an option later on to automatically create this folder if it does not exist |
110 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath); | 110 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath); |
111 | 111 | ||
112 | return loadedNodes; | 112 | return loadedNodes; |
113 | } | 113 | } |
114 | 114 | ||
115 | InventoryFolderBase rootDestinationFolder = folderCandidates[0]; | ||
115 | archive = new TarArchiveReader(m_loadStream); | 116 | archive = new TarArchiveReader(m_loadStream); |
116 | 117 | ||
117 | // In order to load identically named folders, we need to keep track of the folders that we have already | 118 | // In order to load identically named folders, we need to keep track of the folders that we have already |
@@ -188,7 +189,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
188 | /// <summary> | 189 | /// <summary> |
189 | /// Replicate the inventory paths in the archive to the user's inventory as necessary. | 190 | /// Replicate the inventory paths in the archive to the user's inventory as necessary. |
190 | /// </summary> | 191 | /// </summary> |
191 | /// <param name="archivePath">The item archive path to replicate</param> | 192 | /// <param name="iarPath">The item archive path to replicate</param> |
192 | /// <param name="rootDestinationFolder">The root folder for the inventory load</param> | 193 | /// <param name="rootDestinationFolder">The root folder for the inventory load</param> |
193 | /// <param name="resolvedFolders"> | 194 | /// <param name="resolvedFolders"> |
194 | /// The folders that we have resolved so far for a given archive path. | 195 | /// The folders that we have resolved so far for a given archive path. |
@@ -199,24 +200,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
199 | /// </param> | 200 | /// </param> |
200 | /// <returns>The last user inventory folder created or found for the archive path</returns> | 201 | /// <returns>The last user inventory folder created or found for the archive path</returns> |
201 | public InventoryFolderBase ReplicateArchivePathToUserInventory( | 202 | public InventoryFolderBase ReplicateArchivePathToUserInventory( |
202 | string archivePath, | 203 | string iarPath, |
203 | InventoryFolderBase rootDestFolder, | 204 | InventoryFolderBase rootDestFolder, |
204 | Dictionary <string, InventoryFolderBase> resolvedFolders, | 205 | Dictionary <string, InventoryFolderBase> resolvedFolders, |
205 | List<InventoryNodeBase> loadedNodes) | 206 | List<InventoryNodeBase> loadedNodes) |
206 | { | 207 | { |
207 | string originalArchivePath = archivePath; | 208 | string iarPathExisting = iarPath; |
208 | 209 | ||
209 | // m_log.DebugFormat( | 210 | // m_log.DebugFormat( |
210 | // "[INVENTORY ARCHIVER]: Loading folder {0} {1}", rootDestFolder.Name, rootDestFolder.ID); | 211 | // "[INVENTORY ARCHIVER]: Loading folder {0} {1}", rootDestFolder.Name, rootDestFolder.ID); |
211 | 212 | ||
212 | InventoryFolderBase destFolder = ResolveDestinationFolder(rootDestFolder, ref archivePath, resolvedFolders); | 213 | InventoryFolderBase destFolder = ResolveDestinationFolder(rootDestFolder, ref iarPathExisting, resolvedFolders); |
213 | 214 | ||
214 | // m_log.DebugFormat( | 215 | m_log.DebugFormat( |
215 | // "[INVENTORY ARCHIVER]: originalArchivePath [{0}], section already loaded [{1}]", | 216 | "[INVENTORY ARCHIVER]: originalArchivePath [{0}], section already loaded [{1}]", |
216 | // originalArchivePath, archivePath); | 217 | iarPath, iarPathExisting); |
217 | 218 | ||
218 | string archivePathSectionToCreate = originalArchivePath.Substring(archivePath.Length); | 219 | string iarPathToCreate = iarPath.Substring(iarPathExisting.Length); |
219 | CreateFoldersForPath(destFolder, archivePathSectionToCreate, resolvedFolders, loadedNodes); | 220 | CreateFoldersForPath(destFolder, iarPathExisting, iarPathToCreate, resolvedFolders, loadedNodes); |
220 | 221 | ||
221 | return destFolder; | 222 | return destFolder; |
222 | } | 223 | } |
@@ -245,7 +246,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
245 | InventoryFolderBase rootDestFolder, | 246 | InventoryFolderBase rootDestFolder, |
246 | ref string archivePath, | 247 | ref string archivePath, |
247 | Dictionary <string, InventoryFolderBase> resolvedFolders) | 248 | Dictionary <string, InventoryFolderBase> resolvedFolders) |
248 | { | 249 | { |
249 | string originalArchivePath = archivePath; | 250 | string originalArchivePath = archivePath; |
250 | 251 | ||
251 | InventoryFolderBase destFolder = null; | 252 | InventoryFolderBase destFolder = null; |
@@ -254,10 +255,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
254 | { | 255 | { |
255 | while (null == destFolder && archivePath.Length > 0) | 256 | while (null == destFolder && archivePath.Length > 0) |
256 | { | 257 | { |
258 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Trying to resolve destination folder {0}", archivePath); | ||
259 | |||
257 | if (resolvedFolders.ContainsKey(archivePath)) | 260 | if (resolvedFolders.ContainsKey(archivePath)) |
258 | { | 261 | { |
259 | // m_log.DebugFormat( | 262 | m_log.DebugFormat( |
260 | // "[INVENTORY ARCHIVER]: Found previously created folder from archive path {0}", archivePath); | 263 | "[INVENTORY ARCHIVER]: Found previously created folder from archive path {0}", archivePath); |
261 | destFolder = resolvedFolders[archivePath]; | 264 | destFolder = resolvedFolders[archivePath]; |
262 | } | 265 | } |
263 | else | 266 | else |
@@ -294,8 +297,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
294 | /// <param name="destFolder"> | 297 | /// <param name="destFolder"> |
295 | /// The root folder from which the creation will take place. | 298 | /// The root folder from which the creation will take place. |
296 | /// </param> | 299 | /// </param> |
297 | /// <param name="path"> | 300 | /// <param name="iarPathExisting"> |
298 | /// The path to create | 301 | /// the part of the iar path that already exists |
302 | /// </param> | ||
303 | /// <param name="iarPathToReplicate"> | ||
304 | /// The path to replicate in the user's inventory from iar | ||
299 | /// </param> | 305 | /// </param> |
300 | /// <param name="resolvedFolders"> | 306 | /// <param name="resolvedFolders"> |
301 | /// The folders that we have resolved so far for a given archive path. | 307 | /// The folders that we have resolved so far for a given archive path. |
@@ -304,11 +310,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
304 | /// Track the inventory nodes created. | 310 | /// Track the inventory nodes created. |
305 | /// </param> | 311 | /// </param> |
306 | protected void CreateFoldersForPath( | 312 | protected void CreateFoldersForPath( |
307 | InventoryFolderBase destFolder, string path, Dictionary <string, InventoryFolderBase> resolvedFolders, | 313 | InventoryFolderBase destFolder, |
314 | string iarPathExisting, | ||
315 | string iarPathToReplicate, | ||
316 | Dictionary <string, InventoryFolderBase> resolvedFolders, | ||
308 | List<InventoryNodeBase> loadedNodes) | 317 | List<InventoryNodeBase> loadedNodes) |
309 | { | 318 | { |
310 | string pathCreated = ""; | 319 | string[] rawDirsToCreate = iarPathToReplicate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); |
311 | string[] rawDirsToCreate = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); | ||
312 | int i = 0; | 320 | int i = 0; |
313 | 321 | ||
314 | while (i < rawDirsToCreate.Length) | 322 | while (i < rawDirsToCreate.Length) |
@@ -340,9 +348,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
340 | m_scene.InventoryService.AddFolder(destFolder); | 348 | m_scene.InventoryService.AddFolder(destFolder); |
341 | 349 | ||
342 | // Record that we have now created this folder | 350 | // Record that we have now created this folder |
343 | pathCreated += rawDirsToCreate[i] + "/"; | 351 | iarPathExisting += rawDirsToCreate[i] + "/"; |
344 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Created folder {0} from IAR", pathCreated); | 352 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Created folder {0} from IAR", iarPathExisting); |
345 | resolvedFolders[pathCreated] = destFolder; | 353 | resolvedFolders[iarPathExisting] = destFolder; |
346 | 354 | ||
347 | if (0 == i) | 355 | if (0 == i) |
348 | loadedNodes.Add(destFolder); | 356 | loadedNodes.Add(destFolder); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs index 47b18d8..ca33968 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs | |||
@@ -55,8 +55,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
55 | /// | 55 | /// |
56 | /// This method does not handle paths that contain multiple delimitors | 56 | /// This method does not handle paths that contain multiple delimitors |
57 | /// | 57 | /// |
58 | /// FIXME: We do not yet handle situations where folders have the same name. We could handle this by some | 58 | /// FIXME: We have no way of distinguishing folders with the same path |
59 | /// XPath like expression | ||
60 | /// | 59 | /// |
61 | /// FIXME: Delimitors which occur in names themselves are not currently escapable. | 60 | /// FIXME: Delimitors which occur in names themselves are not currently escapable. |
62 | /// | 61 | /// |
@@ -70,14 +69,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
70 | /// The path to the required folder. | 69 | /// The path to the required folder. |
71 | /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned. | 70 | /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned. |
72 | /// </param> | 71 | /// </param> |
73 | /// <returns>null if the folder is not found</returns> | 72 | /// <returns>An empty list if the folder is not found, otherwise a list of all folders that match the name</returns> |
74 | public static InventoryFolderBase FindFolderByPath( | 73 | public static List<InventoryFolderBase> FindFolderByPath( |
75 | IInventoryService inventoryService, UUID userId, string path) | 74 | IInventoryService inventoryService, UUID userId, string path) |
76 | { | 75 | { |
77 | InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); | 76 | InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); |
78 | 77 | ||
79 | if (null == rootFolder) | 78 | if (null == rootFolder) |
80 | return null; | 79 | return new List<InventoryFolderBase>(); |
81 | 80 | ||
82 | return FindFolderByPath(inventoryService, rootFolder, path); | 81 | return FindFolderByPath(inventoryService, rootFolder, path); |
83 | } | 82 | } |
@@ -88,8 +87,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
88 | /// | 87 | /// |
89 | /// This method does not handle paths that contain multiple delimitors | 88 | /// This method does not handle paths that contain multiple delimitors |
90 | /// | 89 | /// |
91 | /// FIXME: We do not yet handle situations where folders have the same name. We could handle this by some | 90 | /// FIXME: We have no way of distinguishing folders with the same path. |
92 | /// XPath like expression | ||
93 | /// | 91 | /// |
94 | /// FIXME: Delimitors which occur in names themselves are not currently escapable. | 92 | /// FIXME: Delimitors which occur in names themselves are not currently escapable. |
95 | /// | 93 | /// |
@@ -103,17 +101,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
103 | /// The path to the required folder. | 101 | /// The path to the required folder. |
104 | /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned. | 102 | /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned. |
105 | /// </param> | 103 | /// </param> |
106 | /// <returns>null if the folder is not found</returns> | 104 | /// <returns>An empty list if the folder is not found, otherwise a list of all folders that match the name</returns> |
107 | public static InventoryFolderBase FindFolderByPath( | 105 | public static List<InventoryFolderBase> FindFolderByPath( |
108 | IInventoryService inventoryService, InventoryFolderBase startFolder, string path) | 106 | IInventoryService inventoryService, InventoryFolderBase startFolder, string path) |
109 | { | 107 | { |
108 | List<InventoryFolderBase> foundFolders = new List<InventoryFolderBase>(); | ||
109 | |||
110 | if (path == string.Empty) | 110 | if (path == string.Empty) |
111 | return startFolder; | 111 | { |
112 | foundFolders.Add(startFolder); | ||
113 | return foundFolders; | ||
114 | } | ||
112 | 115 | ||
113 | path = path.Trim(); | 116 | path = path.Trim(); |
114 | 117 | ||
115 | if (path == PATH_DELIMITER.ToString()) | 118 | if (path == PATH_DELIMITER.ToString()) |
116 | return startFolder; | 119 | { |
120 | foundFolders.Add(startFolder); | ||
121 | return foundFolders; | ||
122 | } | ||
117 | 123 | ||
118 | string[] components = SplitEscapedPath(path); | 124 | string[] components = SplitEscapedPath(path); |
119 | components[0] = UnescapePath(components[0]); | 125 | components[0] = UnescapePath(components[0]); |
@@ -127,14 +133,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
127 | if (folder.Name == components[0]) | 133 | if (folder.Name == components[0]) |
128 | { | 134 | { |
129 | if (components.Length > 1) | 135 | if (components.Length > 1) |
130 | return FindFolderByPath(inventoryService, folder, components[1]); | 136 | foundFolders.AddRange(FindFolderByPath(inventoryService, folder, components[1])); |
131 | else | 137 | else |
132 | return folder; | 138 | foundFolders.Add(folder); |
133 | } | 139 | } |
134 | } | 140 | } |
135 | 141 | ||
136 | // We didn't find a folder with the right name | 142 | return foundFolders; |
137 | return null; | ||
138 | } | 143 | } |
139 | 144 | ||
140 | /// <summary> | 145 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 8f3f65b..2c2724e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |||
@@ -249,9 +249,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
249 | else | 249 | else |
250 | { | 250 | { |
251 | m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER)); | 251 | m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER)); |
252 | inventoryFolder | 252 | List<InventoryFolderBase> candidateFolders |
253 | = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, rootFolder, m_invPath); | 253 | = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, rootFolder, m_invPath); |
254 | //inventoryFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); | 254 | if (candidateFolders.Count > 0) |
255 | inventoryFolder = candidateFolders[0]; | ||
255 | } | 256 | } |
256 | 257 | ||
257 | // The path may point to an item instead | 258 | // The path may point to an item instead |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 00bd27a..5130fa5 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -117,7 +117,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
117 | item1.AssetID = asset1.FullID; | 117 | item1.AssetID = asset1.FullID; |
118 | item1.ID = item1Id; | 118 | item1.ID = item1Id; |
119 | InventoryFolderBase objsFolder | 119 | InventoryFolderBase objsFolder |
120 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); | 120 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0]; |
121 | item1.Folder = objsFolder.ID; | 121 | item1.Folder = objsFolder.ID; |
122 | scene.AddInventoryItem(userId, item1); | 122 | scene.AddInventoryItem(userId, item1); |
123 | 123 | ||
@@ -327,7 +327,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
327 | item1.AssetID = asset1.FullID; | 327 | item1.AssetID = asset1.FullID; |
328 | item1.ID = item1Id; | 328 | item1.ID = item1Id; |
329 | InventoryFolderBase objsFolder | 329 | InventoryFolderBase objsFolder |
330 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); | 330 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0]; |
331 | item1.Folder = objsFolder.ID; | 331 | item1.Folder = objsFolder.ID; |
332 | scene.AddInventoryItem(userId, item1); | 332 | scene.AddInventoryItem(userId, item1); |
333 | 333 | ||
@@ -508,7 +508,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
508 | public void TestNewIarPath() | 508 | public void TestNewIarPath() |
509 | { | 509 | { |
510 | TestHelper.InMethod(); | 510 | TestHelper.InMethod(); |
511 | //log4net.Config.XmlConfigurator.Configure(); | 511 | // log4net.Config.XmlConfigurator.Configure(); |
512 | 512 | ||
513 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | 513 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); |
514 | UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); | 514 | UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); |
@@ -516,33 +516,60 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
516 | Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>(); | 516 | Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>(); |
517 | List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); | 517 | List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); |
518 | 518 | ||
519 | string folder1Name = "a"; | 519 | string folder1Name = "1"; |
520 | string folder2Name = "b"; | 520 | string folder2aName = "2a"; |
521 | string itemName = "c.lsl"; | 521 | string folder2bName = "2b"; |
522 | 522 | ||
523 | string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random()); | 523 | string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random()); |
524 | string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); | 524 | string folder2aArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2aName, UUID.Random()); |
525 | string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); | 525 | string folder2bArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2bName, UUID.Random()); |
526 | 526 | ||
527 | string itemArchivePath | 527 | string iarPath1 = string.Join("", new string[] { folder1ArchiveName, folder2aArchiveName }); |
528 | = string.Format( | 528 | string iarPath2 = string.Join("", new string[] { folder1ArchiveName, folder2bArchiveName }); |
529 | "{0}{1}{2}{3}", | ||
530 | ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName); | ||
531 | 529 | ||
532 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null) | 530 | { |
533 | .ReplicateArchivePathToUserInventory( | 531 | // Test replication of path1 |
534 | itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | 532 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null) |
535 | foldersCreated, nodesLoaded); | 533 | .ReplicateArchivePathToUserInventory( |
536 | 534 | iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | |
537 | InventoryFolderBase folder1 | 535 | foldersCreated, nodesLoaded); |
538 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, "a"); | 536 | |
539 | Assert.That(folder1, Is.Not.Null, "Could not find folder a"); | 537 | List<InventoryFolderBase> folder1Candidates |
540 | InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b"); | 538 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name); |
541 | Assert.That(folder2, Is.Not.Null, "Could not find folder b"); | 539 | Assert.That(folder1Candidates.Count, Is.EqualTo(1)); |
540 | |||
541 | InventoryFolderBase folder1 = folder1Candidates[0]; | ||
542 | List<InventoryFolderBase> folder2aCandidates | ||
543 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName); | ||
544 | Assert.That(folder2aCandidates.Count, Is.EqualTo(1)); | ||
545 | } | ||
546 | |||
547 | { | ||
548 | // Test replication of path2 | ||
549 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null) | ||
550 | .ReplicateArchivePathToUserInventory( | ||
551 | iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | ||
552 | foldersCreated, nodesLoaded); | ||
553 | |||
554 | List<InventoryFolderBase> folder1Candidates | ||
555 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name); | ||
556 | Assert.That(folder1Candidates.Count, Is.EqualTo(1)); | ||
557 | |||
558 | InventoryFolderBase folder1 = folder1Candidates[0]; | ||
559 | |||
560 | List<InventoryFolderBase> folder2aCandidates | ||
561 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName); | ||
562 | Assert.That(folder2aCandidates.Count, Is.EqualTo(1)); | ||
563 | |||
564 | List<InventoryFolderBase> folder2bCandidates | ||
565 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2bName); | ||
566 | Assert.That(folder2bCandidates.Count, Is.EqualTo(1)); | ||
567 | } | ||
542 | } | 568 | } |
543 | 569 | ||
544 | /// <summary> | 570 | /// <summary> |
545 | /// Test replication of a partly existing archive path to the user's inventory. | 571 | /// Test replication of a partly existing archive path to the user's inventory. This should create |
572 | /// a duplicate path without the merge option. | ||
546 | /// </summary> | 573 | /// </summary> |
547 | [Test] | 574 | [Test] |
548 | public void TestPartExistingIarPath() | 575 | public void TestPartExistingIarPath() |
@@ -555,7 +582,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
555 | 582 | ||
556 | string folder1ExistingName = "a"; | 583 | string folder1ExistingName = "a"; |
557 | string folder2Name = "b"; | 584 | string folder2Name = "b"; |
558 | string itemName = "c.lsl"; | ||
559 | 585 | ||
560 | InventoryFolderBase folder1 | 586 | InventoryFolderBase folder1 |
561 | = UserInventoryTestUtils.CreateInventoryFolder( | 587 | = UserInventoryTestUtils.CreateInventoryFolder( |
@@ -563,28 +589,33 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
563 | 589 | ||
564 | string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random()); | 590 | string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random()); |
565 | string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); | 591 | string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); |
566 | string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); | ||
567 | 592 | ||
568 | string itemArchivePath | 593 | string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); |
569 | = string.Format( | 594 | |
570 | "{0}{1}{2}{3}", | ||
571 | ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName); | ||
572 | |||
573 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null) | 595 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null) |
574 | .ReplicateArchivePathToUserInventory( | 596 | .ReplicateArchivePathToUserInventory( |
575 | itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | 597 | itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), |
576 | new Dictionary<string, InventoryFolderBase>(), new List<InventoryNodeBase>()); | 598 | new Dictionary<string, InventoryFolderBase>(), new List<InventoryNodeBase>()); |
577 | 599 | ||
578 | InventoryFolderBase folder1Post | 600 | List<InventoryFolderBase> folder1PostCandidates |
579 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName); | 601 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName); |
580 | Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID)); | 602 | Assert.That(folder1PostCandidates.Count, Is.EqualTo(2)); |
581 | /* | 603 | |
582 | InventoryFolderBase folder2 | 604 | // FIXME: Temporarily, we're going to do something messy to make sure we pick up the created folder. |
605 | InventoryFolderBase folder1Post = null; | ||
606 | foreach (InventoryFolderBase folder in folder1PostCandidates) | ||
607 | { | ||
608 | if (folder.ID != folder1.ID) | ||
609 | { | ||
610 | folder1Post = folder; | ||
611 | break; | ||
612 | } | ||
613 | } | ||
614 | // Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID)); | ||
615 | |||
616 | List<InventoryFolderBase> folder2PostCandidates | ||
583 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b"); | 617 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b"); |
584 | Assert.That(folder2, Is.Not.Null); | 618 | Assert.That(folder2PostCandidates.Count, Is.EqualTo(1)); |
585 | InventoryItemBase item = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, folder2, itemName); | ||
586 | Assert.That(item, Is.Not.Null); | ||
587 | */ | ||
588 | } | 619 | } |
589 | } | 620 | } |
590 | } \ No newline at end of file | 621 | } \ No newline at end of file |
diff --git a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs index 0c7ebca..fecb73f 100644 --- a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs | |||
@@ -84,7 +84,7 @@ namespace OpenSim.Tests.Common.Mock | |||
84 | 84 | ||
85 | public List<InventoryItemBase> getInventoryInFolder(UUID folderID) | 85 | public List<InventoryItemBase> getInventoryInFolder(UUID folderID) |
86 | { | 86 | { |
87 | m_log.DebugFormat("[MOCK INV DB]: Getting items in folder {0}", folderID); | 87 | // m_log.DebugFormat("[MOCK INV DB]: Getting items in folder {0}", folderID); |
88 | 88 | ||
89 | List<InventoryItemBase> items = new List<InventoryItemBase>(); | 89 | List<InventoryItemBase> items = new List<InventoryItemBase>(); |
90 | 90 | ||
@@ -101,7 +101,7 @@ namespace OpenSim.Tests.Common.Mock | |||
101 | 101 | ||
102 | public InventoryFolderBase getUserRootFolder(UUID user) | 102 | public InventoryFolderBase getUserRootFolder(UUID user) |
103 | { | 103 | { |
104 | m_log.DebugFormat("[MOCK INV DB]: Looking for root folder for {0}", user); | 104 | // m_log.DebugFormat("[MOCK INV DB]: Looking for root folder for {0}", user); |
105 | 105 | ||
106 | InventoryFolderBase folder = null; | 106 | InventoryFolderBase folder = null; |
107 | m_rootFolders.TryGetValue(user, out folder); | 107 | m_rootFolders.TryGetValue(user, out folder); |
@@ -141,8 +141,8 @@ namespace OpenSim.Tests.Common.Mock | |||
141 | 141 | ||
142 | if (folder.ParentID == UUID.Zero) | 142 | if (folder.ParentID == UUID.Zero) |
143 | { | 143 | { |
144 | m_log.DebugFormat( | 144 | // m_log.DebugFormat( |
145 | "[MOCK INV DB]: Adding root folder {0} {1} for {2}", folder.Name, folder.ID, folder.Owner); | 145 | // "[MOCK INV DB]: Adding root folder {0} {1} for {2}", folder.Name, folder.ID, folder.Owner); |
146 | m_rootFolders[folder.Owner] = folder; | 146 | m_rootFolders[folder.Owner] = folder; |
147 | } | 147 | } |
148 | } | 148 | } |
@@ -166,8 +166,8 @@ namespace OpenSim.Tests.Common.Mock | |||
166 | 166 | ||
167 | public void addInventoryItem(InventoryItemBase item) | 167 | public void addInventoryItem(InventoryItemBase item) |
168 | { | 168 | { |
169 | m_log.DebugFormat( | 169 | // m_log.DebugFormat( |
170 | "[MOCK INV DB]: Adding inventory item {0} {1} in {2}", item.Name, item.ID, item.Folder); | 170 | // "[MOCK INV DB]: Adding inventory item {0} {1} in {2}", item.Name, item.ID, item.Folder); |
171 | 171 | ||
172 | m_items[item.ID] = item; | 172 | m_items[item.ID] = item; |
173 | } | 173 | } |