diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 29e992e27f..94c6ef9052 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 /// /// Replicate the inventory paths in the archive to the user's inventory as necessary. /// - /// The item archive path to replicate + /// The item archive path to replicate /// The root folder for the inventory load /// /// The folders that we have resolved so far for a given archive path. @@ -200,24 +200,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// /// The last user inventory folder created or found for the archive path public InventoryFolderBase ReplicateArchivePathToUserInventory( - string archivePath, + string iarPath, InventoryFolderBase rootDestFolder, Dictionary resolvedFolders, List loadedNodes) { - string originalArchivePath = archivePath; + string iarPathExisting = iarPath; // m_log.DebugFormat( // "[INVENTORY ARCHIVER]: Loading folder {0} {1}", rootDestFolder.Name, rootDestFolder.ID); - InventoryFolderBase destFolder = ResolveDestinationFolder(rootDestFolder, ref archivePath, resolvedFolders); + InventoryFolderBase destFolder = ResolveDestinationFolder(rootDestFolder, ref iarPathExisting, resolvedFolders); -// m_log.DebugFormat( -// "[INVENTORY ARCHIVER]: originalArchivePath [{0}], section already loaded [{1}]", -// originalArchivePath, archivePath); + m_log.DebugFormat( + "[INVENTORY ARCHIVER]: originalArchivePath [{0}], section already loaded [{1}]", + iarPath, iarPathExisting); - string archivePathSectionToCreate = originalArchivePath.Substring(archivePath.Length); - CreateFoldersForPath(destFolder, archivePathSectionToCreate, resolvedFolders, loadedNodes); + string iarPathToCreate = iarPath.Substring(iarPathExisting.Length); + CreateFoldersForPath(destFolder, iarPathExisting, iarPathToCreate, resolvedFolders, loadedNodes); return destFolder; } @@ -297,8 +297,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// /// The root folder from which the creation will take place. /// - /// - /// The path to create + /// + /// the part of the iar path that already exists + /// + /// + /// The path to replicate in the user's inventory from iar /// /// /// The folders that we have resolved so far for a given archive path. @@ -307,11 +310,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// Track the inventory nodes created. /// protected void CreateFoldersForPath( - InventoryFolderBase destFolder, string path, Dictionary resolvedFolders, + InventoryFolderBase destFolder, + string iarPathExisting, + string iarPathToReplicate, + Dictionary resolvedFolders, List loadedNodes) { - string pathCreated = ""; - string[] rawDirsToCreate = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); + string[] rawDirsToCreate = iarPathToReplicate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); int i = 0; while (i < rawDirsToCreate.Length) @@ -343,9 +348,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_scene.InventoryService.AddFolder(destFolder); // Record that we have now created this folder - pathCreated += rawDirsToCreate[i] + "/"; - m_log.DebugFormat("[INVENTORY ARCHIVER]: Created folder {0} from IAR", pathCreated); - resolvedFolders[pathCreated] = destFolder; + iarPathExisting += rawDirsToCreate[i] + "/"; + m_log.DebugFormat("[INVENTORY ARCHIVER]: Created folder {0} from IAR", iarPathExisting); + resolvedFolders[iarPathExisting] = destFolder; if (0 == i) 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 6bf1219c7f..85afbf9e25 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 public void TestIarV0_1WithEscapedChars() { TestHelper.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); + log4net.Config.XmlConfigurator.Configure(); string itemName = "You & you are a mean/man/"; string humanEscapedItemName = @"You & you are a mean\/man\/"; @@ -542,7 +542,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests } /// - /// Test replication of a partly existing archive path to the user's inventory. + /// Test replication of a partly existing archive path to the user's inventory. This should create + /// a duplicate path without the merge option. /// [Test] public void TestPartExistingIarPath() @@ -555,7 +556,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests string folder1ExistingName = "a"; string folder2Name = "b"; - string itemName = "c.lsl"; InventoryFolderBase folder1 = UserInventoryTestUtils.CreateInventoryFolder( @@ -563,28 +563,36 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random()); string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); - string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); string itemArchivePath = string.Format( - "{0}{1}{2}{3}", - ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName); + "{0}{1}{2}", + ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName); new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null) .ReplicateArchivePathToUserInventory( itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), new Dictionary(), new List()); - InventoryFolderBase folder1Post - = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName)[0]; - Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID)); - /* - InventoryFolderBase folder2 + List folder1PostCandidates + = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName); + Assert.That(folder1PostCandidates.Count, Is.EqualTo(2)); + + // FIXME: Temporarily, we're going to do something messy to make sure we pick up the created folder. + InventoryFolderBase folder1Post = null; + foreach (InventoryFolderBase folder in folder1PostCandidates) + { + if (folder.ID != folder1.ID) + { + folder1Post = folder; + break; + } + } +// Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID)); + + List folder2PostCandidates = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b"); - Assert.That(folder2, Is.Not.Null); - InventoryItemBase item = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, folder2, itemName); - Assert.That(item, Is.Not.Null); - */ + Assert.That(folder2PostCandidates.Count, Is.EqualTo(1)); } } } \ No newline at end of file