refactor iar name generation
slightly change the format of item archive namesremotes/origin/0.6.7-post-fixes
parent
fa1d79533e
commit
76b21860e9
|
@ -138,7 +138,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
|
|
||||||
protected void SaveInvItem(InventoryItemBase inventoryItem, string path)
|
protected void SaveInvItem(InventoryItemBase inventoryItem, string path)
|
||||||
{
|
{
|
||||||
string filename = string.Format("{0}{1}_{2}.xml", path, inventoryItem.Name, inventoryItem.ID);
|
string filename = path + CreateArchiveItemName(inventoryItem);
|
||||||
|
|
||||||
// Record the creator of this item for user record purposes (which might go away soon)
|
// Record the creator of this item for user record purposes (which might go away soon)
|
||||||
m_userUuids[inventoryItem.CreatorIdAsUuid] = 1;
|
m_userUuids[inventoryItem.CreatorIdAsUuid] = 1;
|
||||||
|
@ -162,12 +162,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
{
|
{
|
||||||
if (saveThisFolderItself)
|
if (saveThisFolderItself)
|
||||||
{
|
{
|
||||||
path +=
|
path += CreateArchiveFolderName(inventoryFolder);
|
||||||
string.Format(
|
|
||||||
"{0}{1}{2}/",
|
|
||||||
inventoryFolder.Name,
|
|
||||||
ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR,
|
|
||||||
inventoryFolder.ID);
|
|
||||||
|
|
||||||
// We need to make sure that we record empty folders
|
// We need to make sure that we record empty folders
|
||||||
m_archiveWriter.WriteDir(path);
|
m_archiveWriter.WriteDir(path);
|
||||||
|
@ -356,5 +351,63 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create the archive name for a particular folder.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// These names are prepended with an inventory folder's UUID so that more than one folder can have the
|
||||||
|
/// same name
|
||||||
|
///
|
||||||
|
/// <param name="folder"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string CreateArchiveFolderName(InventoryFolderBase folder)
|
||||||
|
{
|
||||||
|
return CreateArchiveFolderName(folder.Name, folder.ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create the archive name for a particular item.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// These names are prepended with an inventory item's UUID so that more than one item can have the
|
||||||
|
/// same name
|
||||||
|
///
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string CreateArchiveItemName(InventoryItemBase item)
|
||||||
|
{
|
||||||
|
return CreateArchiveItemName(item.Name, item.ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create an archive folder name given its constituent components
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string CreateArchiveFolderName(string name, UUID id)
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
"{0}{1}{2}/",
|
||||||
|
name,
|
||||||
|
ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR,
|
||||||
|
id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create an archive item name given its constituent components
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string CreateArchiveItemName(string name, UUID id)
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
"{0}{1}{2}.xml",
|
||||||
|
name,
|
||||||
|
ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR,
|
||||||
|
id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,19 +153,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
//bool gotControlFile = false;
|
//bool gotControlFile = false;
|
||||||
bool gotObject1File = false;
|
bool gotObject1File = false;
|
||||||
//bool gotObject2File = false;
|
//bool gotObject2File = false;
|
||||||
|
string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1);
|
||||||
string expectedObject1FilePath = string.Format(
|
string expectedObject1FilePath = string.Format(
|
||||||
"{0}{1}/{2}_{3}.xml",
|
"{0}{1}{2}",
|
||||||
ArchiveConstants.INVENTORY_PATH,
|
ArchiveConstants.INVENTORY_PATH,
|
||||||
string.Format(
|
InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder),
|
||||||
"Objects{0}{1}", ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, objsFolder.ID),
|
expectedObject1FileName);
|
||||||
item1.Name,
|
|
||||||
item1Id);
|
|
||||||
|
|
||||||
// string expectedObject2FileName = string.Format(
|
|
||||||
// "{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
|
|
||||||
// part2.Name,
|
|
||||||
// Math.Round(part2.GroupPosition.X), Math.Round(part2.GroupPosition.Y), Math.Round(part2.GroupPosition.Z),
|
|
||||||
// part2.UUID);
|
|
||||||
|
|
||||||
string filePath;
|
string filePath;
|
||||||
TarArchiveReader.TarEntryType tarEntryType;
|
TarArchiveReader.TarEntryType tarEntryType;
|
||||||
|
@ -187,7 +180,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
//
|
//
|
||||||
// if (fileName.StartsWith(part1.Name))
|
// if (fileName.StartsWith(part1.Name))
|
||||||
// {
|
// {
|
||||||
Assert.That(filePath, Is.EqualTo(expectedObject1FilePath));
|
Assert.That(expectedObject1FilePath, Is.EqualTo(filePath));
|
||||||
gotObject1File = true;
|
gotObject1File = true;
|
||||||
// }
|
// }
|
||||||
// else if (fileName.StartsWith(part2.Name))
|
// else if (fileName.StartsWith(part2.Name))
|
||||||
|
@ -385,16 +378,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
string folder2Name = "b";
|
string folder2Name = "b";
|
||||||
string itemName = "c.lsl";
|
string itemName = "c.lsl";
|
||||||
|
|
||||||
string folder1ArchiveName
|
string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random());
|
||||||
= string.Format(
|
string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
|
||||||
"{0}{1}{2}", folder1Name, ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, UUID.Random());
|
string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
|
||||||
string folder2ArchiveName
|
|
||||||
= string.Format(
|
|
||||||
"{0}{1}{2}", folder2Name, ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, UUID.Random());
|
|
||||||
string itemArchivePath
|
string itemArchivePath
|
||||||
= string.Format(
|
= string.Format(
|
||||||
"{0}{1}/{2}/{3}",
|
"{0}{1}{2}{3}",
|
||||||
ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemName);
|
ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName);
|
||||||
|
|
||||||
//Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder);
|
//Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue