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
0.7-release
Justin Clark-Casey (justincc) 2010-06-18 17:37:28 +01:00 committed by Justin Clark-Casey
parent 701cc35c9f
commit 165429ff4d
3 changed files with 58 additions and 35 deletions

View File

@ -247,8 +247,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
ref string archivePath,
Dictionary <string, InventoryFolderBase> resolvedFolders)
{
m_log.DebugFormat("[INVENTORY ARCHIVER]: Resolving destination folder {0}", archivePath);
string originalArchivePath = archivePath;
InventoryFolderBase destFolder = null;
@ -257,6 +255,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
{
while (null == destFolder && archivePath.Length > 0)
{
m_log.DebugFormat("[INVENTORY ARCHIVER]: Trying to resolve destination folder {0}", archivePath);
if (resolvedFolders.ContainsKey(archivePath))
{
m_log.DebugFormat(

View File

@ -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\/";
@ -508,7 +508,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
public void TestNewIarPath()
{
TestHelper.InMethod();
//log4net.Config.XmlConfigurator.Configure();
// log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene("inventory");
UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
@ -516,29 +516,55 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>();
List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>();
string folder1Name = "a";
string folder2Name = "b";
string itemName = "c.lsl";
string folder1Name = "1";
string folder2aName = "2a";
string folder2bName = "2b";
string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random());
string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
string folder2aArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2aName, UUID.Random());
string folder2bArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2bName, UUID.Random());
string itemArchivePath
= string.Format(
"{0}{1}{2}{3}",
ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName);
string iarPath1 = string.Join("", new string[] { folder1ArchiveName, folder2aArchiveName });
string iarPath2 = string.Join("", new string[] { folder1ArchiveName, folder2bArchiveName });
new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null)
.ReplicateArchivePathToUserInventory(
itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
foldersCreated, nodesLoaded);
{
// Test replication of path1
new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null)
.ReplicateArchivePathToUserInventory(
iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
foldersCreated, nodesLoaded);
InventoryFolderBase folder1
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, "a")[0];
Assert.That(folder1, Is.Not.Null, "Could not find folder a");
InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b")[0];
Assert.That(folder2, Is.Not.Null, "Could not find folder b");
List<InventoryFolderBase> folder1Candidates
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
Assert.That(folder1Candidates.Count, Is.EqualTo(1));
InventoryFolderBase folder1 = folder1Candidates[0];
List<InventoryFolderBase> folder2aCandidates
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName);
Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
}
{
// Test replication of path2
new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null)
.ReplicateArchivePathToUserInventory(
iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
foldersCreated, nodesLoaded);
List<InventoryFolderBase> folder1Candidates
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
Assert.That(folder1Candidates.Count, Is.EqualTo(1));
InventoryFolderBase folder1 = folder1Candidates[0];
List<InventoryFolderBase> folder2aCandidates
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName);
Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
List<InventoryFolderBase> folder2bCandidates
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2bName);
Assert.That(folder2bCandidates.Count, Is.EqualTo(1));
}
}
/// <summary>
@ -564,10 +590,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
string itemArchivePath
= string.Format(
"{0}{1}{2}",
ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName);
string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null)
.ReplicateArchivePathToUserInventory(

View File

@ -84,7 +84,7 @@ namespace OpenSim.Tests.Common.Mock
public List<InventoryItemBase> getInventoryInFolder(UUID folderID)
{
m_log.DebugFormat("[MOCK INV DB]: Getting items in folder {0}", folderID);
// m_log.DebugFormat("[MOCK INV DB]: Getting items in folder {0}", folderID);
List<InventoryItemBase> items = new List<InventoryItemBase>();
@ -101,7 +101,7 @@ namespace OpenSim.Tests.Common.Mock
public InventoryFolderBase getUserRootFolder(UUID user)
{
m_log.DebugFormat("[MOCK INV DB]: Looking for root folder for {0}", user);
// m_log.DebugFormat("[MOCK INV DB]: Looking for root folder for {0}", user);
InventoryFolderBase folder = null;
m_rootFolders.TryGetValue(user, out folder);
@ -141,8 +141,8 @@ namespace OpenSim.Tests.Common.Mock
if (folder.ParentID == UUID.Zero)
{
m_log.DebugFormat(
"[MOCK INV DB]: Adding root folder {0} {1} for {2}", folder.Name, folder.ID, folder.Owner);
// m_log.DebugFormat(
// "[MOCK INV DB]: Adding root folder {0} {1} for {2}", folder.Name, folder.ID, folder.Owner);
m_rootFolders[folder.Owner] = folder;
}
}
@ -166,8 +166,8 @@ namespace OpenSim.Tests.Common.Mock
public void addInventoryItem(InventoryItemBase item)
{
m_log.DebugFormat(
"[MOCK INV DB]: Adding inventory item {0} {1} in {2}", item.Name, item.ID, item.Folder);
// m_log.DebugFormat(
// "[MOCK INV DB]: Adding inventory item {0} {1} in {2}", item.Name, item.ID, item.Folder);
m_items[item.ID] = item;
}