diff options
author | Justin Clark-Casey (justincc) | 2010-06-18 17:37:28 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-06-18 17:37:28 +0100 |
commit | 71c8bbaf2c768167e377e86ae7137a86c0bb36d0 (patch) | |
tree | 356e0a08c2066e659330b6341e56a6eaa2555a27 /OpenSim | |
parent | change TestPartExistingIarPath() to check appropriate folder creation (diff) | |
download | opensim-SC-71c8bbaf2c768167e377e86ae7137a86c0bb36d0.zip opensim-SC-71c8bbaf2c768167e377e86ae7137a86c0bb36d0.tar.gz opensim-SC-71c8bbaf2c768167e377e86ae7137a86c0bb36d0.tar.bz2 opensim-SC-71c8bbaf2c768167e377e86ae7137a86c0bb36d0.tar.xz |
Fix problem where iar load would duplicate huge number of folders
This was http://opensimulator.org/mantis/view.php?id=4770
Extend unit tests to check for this scenario too
Diffstat (limited to '')
3 files changed, 58 insertions, 35 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 94c6ef9..9996074 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -246,9 +246,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
246 | InventoryFolderBase rootDestFolder, | 246 | InventoryFolderBase rootDestFolder, |
247 | ref string archivePath, | 247 | ref string archivePath, |
248 | Dictionary <string, InventoryFolderBase> resolvedFolders) | 248 | Dictionary <string, InventoryFolderBase> resolvedFolders) |
249 | { | 249 | { |
250 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Resolving destination folder {0}", archivePath); | ||
251 | |||
252 | string originalArchivePath = archivePath; | 250 | string originalArchivePath = archivePath; |
253 | 251 | ||
254 | InventoryFolderBase destFolder = null; | 252 | InventoryFolderBase destFolder = null; |
@@ -257,6 +255,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
257 | { | 255 | { |
258 | while (null == destFolder && archivePath.Length > 0) | 256 | while (null == destFolder && archivePath.Length > 0) |
259 | { | 257 | { |
258 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Trying to resolve destination folder {0}", archivePath); | ||
259 | |||
260 | if (resolvedFolders.ContainsKey(archivePath)) | 260 | if (resolvedFolders.ContainsKey(archivePath)) |
261 | { | 261 | { |
262 | m_log.DebugFormat( | 262 | m_log.DebugFormat( |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 85afbf9..5130fa5 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\/"; |
@@ -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,29 +516,55 @@ 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")[0]; | 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")[0]; | 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> |
@@ -564,11 +590,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
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 | 592 | ||
567 | string itemArchivePath | 593 | string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); |
568 | = string.Format( | 594 | |
569 | "{0}{1}{2}", | ||
570 | ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName); | ||
571 | |||
572 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null) | 595 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null) |
573 | .ReplicateArchivePathToUserInventory( | 596 | .ReplicateArchivePathToUserInventory( |
574 | itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | 597 | itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), |
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 | } |