refactor: break actual item load in iar into separate method

0.6.8-post-fixes
Justin Clark-Casey (justincc) 2009-11-09 17:04:05 +00:00
parent a0c1836fde
commit ae92bbcb95
1 changed files with 46 additions and 28 deletions

View File

@ -139,28 +139,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
{ {
// Escape back characters InventoryItemBase item = LoadItem(data, foundFolder);
filePath = filePath.Replace("/", "/");
filePath = filePath.Replace("&", "&");
InventoryItemBase item = UserInventoryItemSerializer.Deserialize(data); if (item != null)
{
// Don't use the item ID that's in the file
item.ID = UUID.Random();
UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.CommsManager);
if (UUID.Zero != ospResolvedId)
item.CreatorIdAsUuid = ospResolvedId;
else
item.CreatorIdAsUuid = m_userInfo.UserProfile.ID;
item.Owner = m_userInfo.UserProfile.ID;
// Reset folder ID to the one in which we want to load it
item.Folder = foundFolder.ID;
//m_userInfo.AddItem(item);
m_scene.InventoryService.AddItem(item);
successfulItemRestores++; successfulItemRestores++;
// If we're loading an item directly into the given destination folder then we need to record // If we're loading an item directly into the given destination folder then we need to record
@ -170,6 +152,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
} }
} }
} }
}
archive.Close(); archive.Close();
@ -339,6 +322,41 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
*/ */
} }
/// <summary>
/// Load an item from the archive
/// </summary>
/// <param name="filePath">The archive path for the item</param>
/// <param name="data">The raw item data</param>
/// <param name="rootDestinationFolder">The root destination folder for loaded items</param>
/// <param name="nodesLoaded">All the inventory nodes (items and folders) loaded so far</param>
protected InventoryItemBase LoadItem(byte[] data, InventoryFolderBase loadFolder)
{
// Escape back characters
// filePath = filePath.Replace("&#47;", "/");
// filePath = filePath.Replace("&amp;", "&");
InventoryItemBase item = UserInventoryItemSerializer.Deserialize(data);
// Don't use the item ID that's in the file
item.ID = UUID.Random();
UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.CommsManager);
if (UUID.Zero != ospResolvedId)
item.CreatorIdAsUuid = ospResolvedId;
else
item.CreatorIdAsUuid = m_userInfo.UserProfile.ID;
item.Owner = m_userInfo.UserProfile.ID;
// Reset folder ID to the one in which we want to load it
item.Folder = loadFolder.ID;
//m_userInfo.AddItem(item);
m_scene.InventoryService.AddItem(item);
return item;
}
/// <summary> /// <summary>
/// Load an asset /// Load an asset
/// </summary> /// </summary>