From ae92bbcb95a94b71c74d2ff64e76eb2d0e12af7d Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 9 Nov 2009 17:04:05 +0000
Subject: refactor: break actual item load in iar into separate method
---
.../Archiver/InventoryArchiveReadRequest.cs | 74 ++++++++++++++--------
1 file changed, 46 insertions(+), 28 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 4023c8f..d82d0e3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -138,35 +138,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
rootDestinationFolder, foldersCreated, nodesLoaded);
if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
- {
- // Escape back characters
- filePath = filePath.Replace("/", "/");
- filePath = filePath.Replace("&", "&");
-
- 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 = foundFolder.ID;
-
- //m_userInfo.AddItem(item);
- m_scene.InventoryService.AddItem(item);
- successfulItemRestores++;
+ {
+ InventoryItemBase item = LoadItem(data, foundFolder);
- // If we're loading an item directly into the given destination folder then we need to record
- // it separately from any loaded root folders
- if (rootDestinationFolder == foundFolder)
- nodesLoaded.Add(item);
+ if (item != null)
+ {
+ successfulItemRestores++;
+
+ // If we're loading an item directly into the given destination folder then we need to record
+ // it separately from any loaded root folders
+ if (rootDestinationFolder == foundFolder)
+ nodesLoaded.Add(item);
+ }
}
}
}
@@ -340,6 +323,41 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
}
///
+ /// Load an item from the archive
+ ///
+ /// The archive path for the item
+ /// The raw item data
+ /// The root destination folder for loaded items
+ /// All the inventory nodes (items and folders) loaded so far
+ protected InventoryItemBase LoadItem(byte[] data, InventoryFolderBase loadFolder)
+ {
+ // Escape back characters
+// filePath = filePath.Replace("/", "/");
+// filePath = filePath.Replace("&", "&");
+
+ 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;
+ }
+
+ ///
/// Load an asset
///
///
--
cgit v1.1