change TestPartExistingIarPath() to check appropriate folder creation
change some names in InventoryArchiveReadRequest in an effort to make the code more comprehendable0.7-release
parent
cf4721a92d
commit
11a35d8cda
|
@ -189,7 +189,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|||
/// <summary>
|
||||
/// Replicate the inventory paths in the archive to the user's inventory as necessary.
|
||||
/// </summary>
|
||||
/// <param name="archivePath">The item archive path to replicate</param>
|
||||
/// <param name="iarPath">The item archive path to replicate</param>
|
||||
/// <param name="rootDestinationFolder">The root folder for the inventory load</param>
|
||||
/// <param name="resolvedFolders">
|
||||
/// The folders that we have resolved so far for a given archive path.
|
||||
|
@ -200,24 +200,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|||
/// </param>
|
||||
/// <returns>The last user inventory folder created or found for the archive path</returns>
|
||||
public InventoryFolderBase ReplicateArchivePathToUserInventory(
|
||||
string archivePath,
|
||||
string iarPath,
|
||||
InventoryFolderBase rootDestFolder,
|
||||
Dictionary <string, InventoryFolderBase> resolvedFolders,
|
||||
List<InventoryNodeBase> 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
|
|||
/// <param name="destFolder">
|
||||
/// The root folder from which the creation will take place.
|
||||
/// </param>
|
||||
/// <param name="path">
|
||||
/// The path to create
|
||||
/// <param name="iarPathExisting">
|
||||
/// the part of the iar path that already exists
|
||||
/// </param>
|
||||
/// <param name="iarPathToReplicate">
|
||||
/// The path to replicate in the user's inventory from iar
|
||||
/// </param>
|
||||
/// <param name="resolvedFolders">
|
||||
/// 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.
|
||||
/// </param>
|
||||
protected void CreateFoldersForPath(
|
||||
InventoryFolderBase destFolder, string path, Dictionary <string, InventoryFolderBase> resolvedFolders,
|
||||
InventoryFolderBase destFolder,
|
||||
string iarPathExisting,
|
||||
string iarPathToReplicate,
|
||||
Dictionary <string, InventoryFolderBase> resolvedFolders,
|
||||
List<InventoryNodeBase> 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);
|
||||
|
|
|
@ -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
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
[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<string, InventoryFolderBase>(), new List<InventoryNodeBase>());
|
||||
|
||||
InventoryFolderBase folder1Post
|
||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName)[0];
|
||||
Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID));
|
||||
/*
|
||||
InventoryFolderBase folder2
|
||||
List<InventoryFolderBase> 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<InventoryFolderBase> 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));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue