diff options
author | Justin Clark-Casey (justincc) | 2010-06-18 17:10:16 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-06-18 17:10:16 +0100 |
commit | 11a35d8cdaac00ac563c2f44fdb28342ca95e142 (patch) | |
tree | 394d68e759047d124983fa0e91f9a3878030f354 /OpenSim/Region/CoreModules | |
parent | in IAR utils, return all folders that match a particular path rather than jus... (diff) | |
download | opensim-SC_OLD-11a35d8cdaac00ac563c2f44fdb28342ca95e142.zip opensim-SC_OLD-11a35d8cdaac00ac563c2f44fdb28342ca95e142.tar.gz opensim-SC_OLD-11a35d8cdaac00ac563c2f44fdb28342ca95e142.tar.bz2 opensim-SC_OLD-11a35d8cdaac00ac563c2f44fdb28342ca95e142.tar.xz |
change TestPartExistingIarPath() to check appropriate folder creation
change some names in InventoryArchiveReadRequest in an effort to make the code more comprehendable
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 39 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | 38 |
2 files changed, 45 insertions, 32 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 29e992e..94c6ef9 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -189,7 +189,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
189 | /// <summary> | 189 | /// <summary> |
190 | /// 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. |
191 | /// </summary> | 191 | /// </summary> |
192 | /// <param name="archivePath">The item archive path to replicate</param> | 192 | /// <param name="iarPath">The item archive path to replicate</param> |
193 | /// <param name="rootDestinationFolder">The root folder for the inventory load</param> | 193 | /// <param name="rootDestinationFolder">The root folder for the inventory load</param> |
194 | /// <param name="resolvedFolders"> | 194 | /// <param name="resolvedFolders"> |
195 | /// 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. |
@@ -200,24 +200,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
200 | /// </param> | 200 | /// </param> |
201 | /// <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> |
202 | public InventoryFolderBase ReplicateArchivePathToUserInventory( | 202 | public InventoryFolderBase ReplicateArchivePathToUserInventory( |
203 | string archivePath, | 203 | string iarPath, |
204 | InventoryFolderBase rootDestFolder, | 204 | InventoryFolderBase rootDestFolder, |
205 | Dictionary <string, InventoryFolderBase> resolvedFolders, | 205 | Dictionary <string, InventoryFolderBase> resolvedFolders, |
206 | List<InventoryNodeBase> loadedNodes) | 206 | List<InventoryNodeBase> loadedNodes) |
207 | { | 207 | { |
208 | string originalArchivePath = archivePath; | 208 | string iarPathExisting = iarPath; |
209 | 209 | ||
210 | // m_log.DebugFormat( | 210 | // m_log.DebugFormat( |
211 | // "[INVENTORY ARCHIVER]: Loading folder {0} {1}", rootDestFolder.Name, rootDestFolder.ID); | 211 | // "[INVENTORY ARCHIVER]: Loading folder {0} {1}", rootDestFolder.Name, rootDestFolder.ID); |
212 | 212 | ||
213 | InventoryFolderBase destFolder = ResolveDestinationFolder(rootDestFolder, ref archivePath, resolvedFolders); | 213 | InventoryFolderBase destFolder = ResolveDestinationFolder(rootDestFolder, ref iarPathExisting, resolvedFolders); |
214 | 214 | ||
215 | // m_log.DebugFormat( | 215 | m_log.DebugFormat( |
216 | // "[INVENTORY ARCHIVER]: originalArchivePath [{0}], section already loaded [{1}]", | 216 | "[INVENTORY ARCHIVER]: originalArchivePath [{0}], section already loaded [{1}]", |
217 | // originalArchivePath, archivePath); | 217 | iarPath, iarPathExisting); |
218 | 218 | ||
219 | string archivePathSectionToCreate = originalArchivePath.Substring(archivePath.Length); | 219 | string iarPathToCreate = iarPath.Substring(iarPathExisting.Length); |
220 | CreateFoldersForPath(destFolder, archivePathSectionToCreate, resolvedFolders, loadedNodes); | 220 | CreateFoldersForPath(destFolder, iarPathExisting, iarPathToCreate, resolvedFolders, loadedNodes); |
221 | 221 | ||
222 | return destFolder; | 222 | return destFolder; |
223 | } | 223 | } |
@@ -297,8 +297,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
297 | /// <param name="destFolder"> | 297 | /// <param name="destFolder"> |
298 | /// The root folder from which the creation will take place. | 298 | /// The root folder from which the creation will take place. |
299 | /// </param> | 299 | /// </param> |
300 | /// <param name="path"> | 300 | /// <param name="iarPathExisting"> |
301 | /// 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 | ||
302 | /// </param> | 305 | /// </param> |
303 | /// <param name="resolvedFolders"> | 306 | /// <param name="resolvedFolders"> |
304 | /// 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. |
@@ -307,11 +310,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
307 | /// Track the inventory nodes created. | 310 | /// Track the inventory nodes created. |
308 | /// </param> | 311 | /// </param> |
309 | protected void CreateFoldersForPath( | 312 | protected void CreateFoldersForPath( |
310 | InventoryFolderBase destFolder, string path, Dictionary <string, InventoryFolderBase> resolvedFolders, | 313 | InventoryFolderBase destFolder, |
314 | string iarPathExisting, | ||
315 | string iarPathToReplicate, | ||
316 | Dictionary <string, InventoryFolderBase> resolvedFolders, | ||
311 | List<InventoryNodeBase> loadedNodes) | 317 | List<InventoryNodeBase> loadedNodes) |
312 | { | 318 | { |
313 | string pathCreated = ""; | 319 | string[] rawDirsToCreate = iarPathToReplicate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); |
314 | string[] rawDirsToCreate = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); | ||
315 | int i = 0; | 320 | int i = 0; |
316 | 321 | ||
317 | while (i < rawDirsToCreate.Length) | 322 | while (i < rawDirsToCreate.Length) |
@@ -343,9 +348,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
343 | m_scene.InventoryService.AddFolder(destFolder); | 348 | m_scene.InventoryService.AddFolder(destFolder); |
344 | 349 | ||
345 | // Record that we have now created this folder | 350 | // Record that we have now created this folder |
346 | pathCreated += rawDirsToCreate[i] + "/"; | 351 | iarPathExisting += rawDirsToCreate[i] + "/"; |
347 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Created folder {0} from IAR", pathCreated); | 352 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Created folder {0} from IAR", iarPathExisting); |
348 | resolvedFolders[pathCreated] = destFolder; | 353 | resolvedFolders[iarPathExisting] = destFolder; |
349 | 354 | ||
350 | if (0 == i) | 355 | if (0 == i) |
351 | loadedNodes.Add(destFolder); | 356 | loadedNodes.Add(destFolder); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 6bf1219..85afbf9 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -279,7 +279,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
279 | public void TestIarV0_1WithEscapedChars() | 279 | public void TestIarV0_1WithEscapedChars() |
280 | { | 280 | { |
281 | TestHelper.InMethod(); | 281 | TestHelper.InMethod(); |
282 | // log4net.Config.XmlConfigurator.Configure(); | 282 | log4net.Config.XmlConfigurator.Configure(); |
283 | 283 | ||
284 | string itemName = "You & you are a mean/man/"; | 284 | string itemName = "You & you are a mean/man/"; |
285 | string humanEscapedItemName = @"You & you are a mean\/man\/"; | 285 | string humanEscapedItemName = @"You & you are a mean\/man\/"; |
@@ -542,7 +542,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
542 | } | 542 | } |
543 | 543 | ||
544 | /// <summary> | 544 | /// <summary> |
545 | /// Test replication of a partly existing archive path to the user's inventory. | 545 | /// Test replication of a partly existing archive path to the user's inventory. This should create |
546 | /// a duplicate path without the merge option. | ||
546 | /// </summary> | 547 | /// </summary> |
547 | [Test] | 548 | [Test] |
548 | public void TestPartExistingIarPath() | 549 | public void TestPartExistingIarPath() |
@@ -555,7 +556,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
555 | 556 | ||
556 | string folder1ExistingName = "a"; | 557 | string folder1ExistingName = "a"; |
557 | string folder2Name = "b"; | 558 | string folder2Name = "b"; |
558 | string itemName = "c.lsl"; | ||
559 | 559 | ||
560 | InventoryFolderBase folder1 | 560 | InventoryFolderBase folder1 |
561 | = UserInventoryTestUtils.CreateInventoryFolder( | 561 | = UserInventoryTestUtils.CreateInventoryFolder( |
@@ -563,28 +563,36 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
563 | 563 | ||
564 | string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random()); | 564 | string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random()); |
565 | string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); | 565 | string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); |
566 | string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); | ||
567 | 566 | ||
568 | string itemArchivePath | 567 | string itemArchivePath |
569 | = string.Format( | 568 | = string.Format( |
570 | "{0}{1}{2}{3}", | 569 | "{0}{1}{2}", |
571 | ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName); | 570 | ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName); |
572 | 571 | ||
573 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null) | 572 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null) |
574 | .ReplicateArchivePathToUserInventory( | 573 | .ReplicateArchivePathToUserInventory( |
575 | itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | 574 | itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), |
576 | new Dictionary<string, InventoryFolderBase>(), new List<InventoryNodeBase>()); | 575 | new Dictionary<string, InventoryFolderBase>(), new List<InventoryNodeBase>()); |
577 | 576 | ||
578 | InventoryFolderBase folder1Post | 577 | List<InventoryFolderBase> folder1PostCandidates |
579 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName)[0]; | 578 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName); |
580 | Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID)); | 579 | Assert.That(folder1PostCandidates.Count, Is.EqualTo(2)); |
581 | /* | 580 | |
582 | InventoryFolderBase folder2 | 581 | // FIXME: Temporarily, we're going to do something messy to make sure we pick up the created folder. |
582 | InventoryFolderBase folder1Post = null; | ||
583 | foreach (InventoryFolderBase folder in folder1PostCandidates) | ||
584 | { | ||
585 | if (folder.ID != folder1.ID) | ||
586 | { | ||
587 | folder1Post = folder; | ||
588 | break; | ||
589 | } | ||
590 | } | ||
591 | // Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID)); | ||
592 | |||
593 | List<InventoryFolderBase> folder2PostCandidates | ||
583 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b"); | 594 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b"); |
584 | Assert.That(folder2, Is.Not.Null); | 595 | 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 | } | 596 | } |
589 | } | 597 | } |
590 | } \ No newline at end of file | 598 | } \ No newline at end of file |