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>
|
/// <summary>
|
||||||
/// Replicate the inventory paths in the archive to the user's inventory as necessary.
|
/// Replicate the inventory paths in the archive to the user's inventory as necessary.
|
||||||
/// </summary>
|
/// </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="rootDestinationFolder">The root folder for the inventory load</param>
|
||||||
/// <param name="resolvedFolders">
|
/// <param name="resolvedFolders">
|
||||||
/// The folders that we have resolved so far for a given archive path.
|
/// 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>
|
/// </param>
|
||||||
/// <returns>The last user inventory folder created or found for the archive path</returns>
|
/// <returns>The last user inventory folder created or found for the archive path</returns>
|
||||||
public InventoryFolderBase ReplicateArchivePathToUserInventory(
|
public InventoryFolderBase ReplicateArchivePathToUserInventory(
|
||||||
string archivePath,
|
string iarPath,
|
||||||
InventoryFolderBase rootDestFolder,
|
InventoryFolderBase rootDestFolder,
|
||||||
Dictionary <string, InventoryFolderBase> resolvedFolders,
|
Dictionary <string, InventoryFolderBase> resolvedFolders,
|
||||||
List<InventoryNodeBase> loadedNodes)
|
List<InventoryNodeBase> loadedNodes)
|
||||||
{
|
{
|
||||||
string originalArchivePath = archivePath;
|
string iarPathExisting = iarPath;
|
||||||
|
|
||||||
// m_log.DebugFormat(
|
// m_log.DebugFormat(
|
||||||
// "[INVENTORY ARCHIVER]: Loading folder {0} {1}", rootDestFolder.Name, rootDestFolder.ID);
|
// "[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(
|
m_log.DebugFormat(
|
||||||
// "[INVENTORY ARCHIVER]: originalArchivePath [{0}], section already loaded [{1}]",
|
"[INVENTORY ARCHIVER]: originalArchivePath [{0}], section already loaded [{1}]",
|
||||||
// originalArchivePath, archivePath);
|
iarPath, iarPathExisting);
|
||||||
|
|
||||||
string archivePathSectionToCreate = originalArchivePath.Substring(archivePath.Length);
|
string iarPathToCreate = iarPath.Substring(iarPathExisting.Length);
|
||||||
CreateFoldersForPath(destFolder, archivePathSectionToCreate, resolvedFolders, loadedNodes);
|
CreateFoldersForPath(destFolder, iarPathExisting, iarPathToCreate, resolvedFolders, loadedNodes);
|
||||||
|
|
||||||
return destFolder;
|
return destFolder;
|
||||||
}
|
}
|
||||||
|
@ -297,8 +297,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
/// <param name="destFolder">
|
/// <param name="destFolder">
|
||||||
/// The root folder from which the creation will take place.
|
/// The root folder from which the creation will take place.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <param name="path">
|
/// <param name="iarPathExisting">
|
||||||
/// The path to create
|
/// 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>
|
||||||
/// <param name="resolvedFolders">
|
/// <param name="resolvedFolders">
|
||||||
/// The folders that we have resolved so far for a given archive path.
|
/// 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.
|
/// Track the inventory nodes created.
|
||||||
/// </param>
|
/// </param>
|
||||||
protected void CreateFoldersForPath(
|
protected void CreateFoldersForPath(
|
||||||
InventoryFolderBase destFolder, string path, Dictionary <string, InventoryFolderBase> resolvedFolders,
|
InventoryFolderBase destFolder,
|
||||||
|
string iarPathExisting,
|
||||||
|
string iarPathToReplicate,
|
||||||
|
Dictionary <string, InventoryFolderBase> resolvedFolders,
|
||||||
List<InventoryNodeBase> loadedNodes)
|
List<InventoryNodeBase> loadedNodes)
|
||||||
{
|
{
|
||||||
string pathCreated = "";
|
string[] rawDirsToCreate = iarPathToReplicate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
string[] rawDirsToCreate = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (i < rawDirsToCreate.Length)
|
while (i < rawDirsToCreate.Length)
|
||||||
|
@ -343,9 +348,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
m_scene.InventoryService.AddFolder(destFolder);
|
m_scene.InventoryService.AddFolder(destFolder);
|
||||||
|
|
||||||
// Record that we have now created this folder
|
// Record that we have now created this folder
|
||||||
pathCreated += rawDirsToCreate[i] + "/";
|
iarPathExisting += rawDirsToCreate[i] + "/";
|
||||||
m_log.DebugFormat("[INVENTORY ARCHIVER]: Created folder {0} from IAR", pathCreated);
|
m_log.DebugFormat("[INVENTORY ARCHIVER]: Created folder {0} from IAR", iarPathExisting);
|
||||||
resolvedFolders[pathCreated] = destFolder;
|
resolvedFolders[iarPathExisting] = destFolder;
|
||||||
|
|
||||||
if (0 == i)
|
if (0 == i)
|
||||||
loadedNodes.Add(destFolder);
|
loadedNodes.Add(destFolder);
|
||||||
|
|
|
@ -279,7 +279,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
public void TestIarV0_1WithEscapedChars()
|
public void TestIarV0_1WithEscapedChars()
|
||||||
{
|
{
|
||||||
TestHelper.InMethod();
|
TestHelper.InMethod();
|
||||||
// log4net.Config.XmlConfigurator.Configure();
|
log4net.Config.XmlConfigurator.Configure();
|
||||||
|
|
||||||
string itemName = "You & you are a mean/man/";
|
string itemName = "You & you are a mean/man/";
|
||||||
string humanEscapedItemName = @"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>
|
/// <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>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void TestPartExistingIarPath()
|
public void TestPartExistingIarPath()
|
||||||
|
@ -555,7 +556,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
|
|
||||||
string folder1ExistingName = "a";
|
string folder1ExistingName = "a";
|
||||||
string folder2Name = "b";
|
string folder2Name = "b";
|
||||||
string itemName = "c.lsl";
|
|
||||||
|
|
||||||
InventoryFolderBase folder1
|
InventoryFolderBase folder1
|
||||||
= UserInventoryTestUtils.CreateInventoryFolder(
|
= UserInventoryTestUtils.CreateInventoryFolder(
|
||||||
|
@ -563,28 +563,36 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
|
|
||||||
string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
|
string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
|
||||||
string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
|
string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
|
||||||
string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
|
|
||||||
|
|
||||||
string itemArchivePath
|
string itemArchivePath
|
||||||
= string.Format(
|
= string.Format(
|
||||||
"{0}{1}{2}{3}",
|
"{0}{1}{2}",
|
||||||
ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName);
|
ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName);
|
||||||
|
|
||||||
new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null)
|
new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null)
|
||||||
.ReplicateArchivePathToUserInventory(
|
.ReplicateArchivePathToUserInventory(
|
||||||
itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
|
itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
|
||||||
new Dictionary<string, InventoryFolderBase>(), new List<InventoryNodeBase>());
|
new Dictionary<string, InventoryFolderBase>(), new List<InventoryNodeBase>());
|
||||||
|
|
||||||
InventoryFolderBase folder1Post
|
List<InventoryFolderBase> folder1PostCandidates
|
||||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName)[0];
|
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
|
||||||
Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID));
|
Assert.That(folder1PostCandidates.Count, Is.EqualTo(2));
|
||||||
/*
|
|
||||||
InventoryFolderBase folder2
|
// 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");
|
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b");
|
||||||
Assert.That(folder2, Is.Not.Null);
|
Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
|
||||||
InventoryItemBase item = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, folder2, itemName);
|
|
||||||
Assert.That(item, Is.Not.Null);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue