From 8a2360bf815d4d78fcff34a69dec24782494bd2e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 9 Mar 2011 01:21:31 +0000 Subject: Simplify TestLoadIarV0_1AbsentUsers() to use common IAR test setup. Make static dictionaries on NullUserAccountData instance instead to stop user accounts being carried over between tests --- .../Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 6030706..7849d88 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -400,6 +400,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService); if (UUID.Zero != ospResolvedId) // The user exists in this grid { +// m_log.DebugFormat("[INVENTORY ARCHIVER]: Found creator {0} via OSPA resolution", ospResolvedId); + item.CreatorIdAsUuid = ospResolvedId; // XXX: For now, don't preserve the OSPA in the creator id (which actually gets persisted to the -- cgit v1.1 From b821f748ac591258f015ecf3ba8011d5561c488d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 10 Mar 2011 21:56:15 +0000 Subject: For objects loaded from an IAR, make sure the CreatorID points towards the OSP resolved ID if newer CreationData is not present. This should resolve issues where the creator for rezzed objects was being shown as "Unknown user" where previous behaviour was to show the OSP resolved account. This is being done by parsing the serialized objects and updating the CreatorID if no CreationData exists. This operation might be expensive for sculpties where the sculpt texture is inlined with the object data. Will just have to see. This relies on the IAR streaming inventory data before asset data (as is currently the case). Will need to introduce more stringent checks for file order on loading (much like JAR zips must start with the manifest file). This is for IAR loading only. Tests updated to check this behaviour. --- .../Archiver/InventoryArchiveReadRequest.cs | 40 ++++++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 7849d88..d0510d3 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -41,6 +41,7 @@ using OpenSim.Framework.Serialization; using OpenSim.Framework.Serialization.External; using OpenSim.Region.CoreModules.World.Archiver; using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Region.Framework.Interfaces; using OpenSim.Services.Interfaces; @@ -75,6 +76,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// The stream from which the inventory archive will be loaded. /// private Stream m_loadStream; + + /// + /// Record the creator id that should be associated with an asset. This is used to adjust asset creator ids + /// after OSP resolution (since OSP creators are only stored in the item + /// + protected Dictionary m_creatorIdForAssetId = new Dictionary(); public InventoryArchiveReadRequest( Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge) @@ -420,6 +427,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // Reset folder ID to the one in which we want to load it item.Folder = loadFolder.ID; + // Record the creator id for the item's asset so that we can use it later, if necessary, when the asset + // is loaded. + // FIXME: This relies on the items coming before the assets in the TAR file. Need to create stronger + // checks for this, and maybe even an external tool for creating OARs which enforces this, rather than + // relying on native tar tools. + m_creatorIdForAssetId[item.AssetID] = item.CreatorIdAsUuid; + m_scene.AddInventoryItem(item); return item; @@ -448,18 +462,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } string extension = filename.Substring(i); - string uuid = filename.Remove(filename.Length - extension.Length); + string rawUuid = filename.Remove(filename.Length - extension.Length); + UUID assetId = new UUID(rawUuid); if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) { sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; if (assetType == (sbyte)AssetType.Unknown) - m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, uuid); + { + m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, assetId); + } + else if (assetType == (sbyte)AssetType.Object) + { + if (m_creatorIdForAssetId.ContainsKey(assetId)) + { + string xmlData = Utils.BytesToString(data); + SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); + foreach (SceneObjectPart sop in sog.Parts) + { + if (sop.CreatorData == null || sop.CreatorData == "") + { + sop.CreatorID = m_creatorIdForAssetId[assetId]; + } + } + + data = Utils.StringToBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog)); + } + } //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); - AssetBase asset = new AssetBase(new UUID(uuid), "RandomName", assetType, UUID.Zero.ToString()); + AssetBase asset = new AssetBase(assetId, "From IAR", assetType, UUID.Zero.ToString()); asset.Data = data; m_scene.AssetService.Store(asset); -- cgit v1.1 From ce4421497e47d709018e6aba9e99317d6a936b98 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 10 Mar 2011 22:38:52 +0000 Subject: re-enable item.CreatorId check in TestLoadIarV0_1AbsentCreator() --- .../Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index d0510d3..7d50e51 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -411,7 +411,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver item.CreatorIdAsUuid = ospResolvedId; - // XXX: For now, don't preserve the OSPA in the creator id (which actually gets persisted to the + // Don't preserve the OSPA in the creator id (which actually gets persisted to the // database). Instead, replace with the UUID that we found. item.CreatorId = ospResolvedId.ToString(); @@ -419,7 +419,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } else if (item.CreatorData == null || item.CreatorData == String.Empty) { - item.CreatorIdAsUuid = m_userInfo.PrincipalID; + item.CreatorId = m_userInfo.PrincipalID.ToString(); + item.CreatorIdAsUuid = new UUID(item.CreatorId); } item.Owner = m_userInfo.PrincipalID; -- cgit v1.1 From 367ed585e0f4a7e4d540230c586531abd75e2228 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 12 Mar 2011 00:21:52 +0000 Subject: introduce iar load checks which make sure archive.xml comes first, then inventory nodes, then assets this is necessary for correct loading. "save iar" always saves in this order so there shouldn't be any problems - these checks are to give better feedback to other systems that may construct IARs. --- .../Archiver/InventoryArchiveReadRequest.cs | 33 +++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 7d50e51..4d97c0a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -111,6 +111,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// A list of the inventory nodes loaded. If folders were loaded then only the root folders are /// returned /// + /// Thrown if load fails. public HashSet Execute() { try @@ -143,15 +144,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver byte[] data; TarArchiveReader.TarEntryType entryType; + bool controlFileLoaded = false, assetsLoaded = false, inventoryNodesLoaded = false; while ((data = archive.ReadEntry(out filePath, out entryType)) != null) { if (filePath == ArchiveConstants.CONTROL_FILE_PATH) { LoadControlFile(filePath, data); + controlFileLoaded = true; } else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) { + if (!controlFileLoaded) + throw new Exception( + string.Format( + "The IAR you are trying to load does not list {0} before {1}. Aborting load", + ArchiveConstants.CONTROL_FILE_PATH, ArchiveConstants.ASSETS_PATH)); + + if (!inventoryNodesLoaded) + throw new Exception( + string.Format( + "The IAR you are trying to load does not list all {0} before {1}. Aborting load", + ArchiveConstants.INVENTORY_PATH, ArchiveConstants.ASSETS_PATH)); + if (LoadAsset(filePath, data)) successfulAssetRestores++; else @@ -160,10 +175,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if ((successfulAssetRestores) % 50 == 0) m_log.DebugFormat( "[INVENTORY ARCHIVER]: Loaded {0} assets...", - successfulAssetRestores); + successfulAssetRestores); + + assetsLoaded = true; } else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) { + if (!controlFileLoaded) + throw new Exception( + string.Format( + "The IAR you are trying to load does not list {0} before {1}. Aborting load", + ArchiveConstants.CONTROL_FILE_PATH, ArchiveConstants.INVENTORY_PATH)); + + if (assetsLoaded) + throw new Exception( + string.Format( + "The IAR you are trying to load does not list all {0} before {1}. Aborting load", + ArchiveConstants.INVENTORY_PATH, ArchiveConstants.ASSETS_PATH)); + filePath = filePath.Substring(ArchiveConstants.INVENTORY_PATH.Length); // Trim off the file portion if we aren't already dealing with a directory path @@ -188,6 +217,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver loadedNodes.Add(item); } } + + inventoryNodesLoaded = true; } } -- cgit v1.1 From a3c7c04ead1b1388d2093edf66d37edecdeccc61 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 12 Mar 2011 00:28:23 +0000 Subject: refactor: make boolean load indicators on load iars instance fields --- .../Inventory/Archiver/InventoryArchiveReadRequest.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 4d97c0a..367960c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -82,6 +82,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// after OSP resolution (since OSP creators are only stored in the item /// protected Dictionary m_creatorIdForAssetId = new Dictionary(); + + protected bool m_controlFileLoaded; + protected bool m_assetsLoaded; + protected bool m_inventoryNodesLoaded; public InventoryArchiveReadRequest( Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge) @@ -144,24 +148,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver byte[] data; TarArchiveReader.TarEntryType entryType; - bool controlFileLoaded = false, assetsLoaded = false, inventoryNodesLoaded = false; while ((data = archive.ReadEntry(out filePath, out entryType)) != null) { if (filePath == ArchiveConstants.CONTROL_FILE_PATH) { LoadControlFile(filePath, data); - controlFileLoaded = true; + m_controlFileLoaded = true; } else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) { - if (!controlFileLoaded) + if (!m_controlFileLoaded) throw new Exception( string.Format( "The IAR you are trying to load does not list {0} before {1}. Aborting load", ArchiveConstants.CONTROL_FILE_PATH, ArchiveConstants.ASSETS_PATH)); - if (!inventoryNodesLoaded) + if (!m_inventoryNodesLoaded) throw new Exception( string.Format( "The IAR you are trying to load does not list all {0} before {1}. Aborting load", @@ -177,17 +180,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver "[INVENTORY ARCHIVER]: Loaded {0} assets...", successfulAssetRestores); - assetsLoaded = true; + m_assetsLoaded = true; } else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) { - if (!controlFileLoaded) + if (!m_controlFileLoaded) throw new Exception( string.Format( "The IAR you are trying to load does not list {0} before {1}. Aborting load", ArchiveConstants.CONTROL_FILE_PATH, ArchiveConstants.INVENTORY_PATH)); - if (assetsLoaded) + if (m_assetsLoaded) throw new Exception( string.Format( "The IAR you are trying to load does not list all {0} before {1}. Aborting load", @@ -218,7 +221,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } } - inventoryNodesLoaded = true; + m_inventoryNodesLoaded = true; } } -- cgit v1.1 From c4060e56ef2aa2d4d68d33ae3081c6a0d2d37f7c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 12 Mar 2011 00:35:40 +0000 Subject: factor out iar asset load code into its own method --- .../Archiver/InventoryArchiveReadRequest.cs | 69 +++++++++++++--------- 1 file changed, 40 insertions(+), 29 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 367960c..cf4ba91 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -86,6 +86,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver protected bool m_controlFileLoaded; protected bool m_assetsLoaded; protected bool m_inventoryNodesLoaded; + + protected int m_successfulAssetRestores; + protected int m_failedAssetRestores; public InventoryArchiveReadRequest( Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge) @@ -121,8 +124,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver try { string filePath = "ERROR"; - int successfulAssetRestores = 0; - int failedAssetRestores = 0; int successfulItemRestores = 0; HashSet loadedNodes = new HashSet(); @@ -154,33 +155,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (filePath == ArchiveConstants.CONTROL_FILE_PATH) { LoadControlFile(filePath, data); - m_controlFileLoaded = true; - } + } else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) { - if (!m_controlFileLoaded) - throw new Exception( - string.Format( - "The IAR you are trying to load does not list {0} before {1}. Aborting load", - ArchiveConstants.CONTROL_FILE_PATH, ArchiveConstants.ASSETS_PATH)); - - if (!m_inventoryNodesLoaded) - throw new Exception( - string.Format( - "The IAR you are trying to load does not list all {0} before {1}. Aborting load", - ArchiveConstants.INVENTORY_PATH, ArchiveConstants.ASSETS_PATH)); - - if (LoadAsset(filePath, data)) - successfulAssetRestores++; - else - failedAssetRestores++; - - if ((successfulAssetRestores) % 50 == 0) - m_log.DebugFormat( - "[INVENTORY ARCHIVER]: Loaded {0} assets...", - successfulAssetRestores); - - m_assetsLoaded = true; + LoadAssetFile(filePath, data); } else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) { @@ -229,7 +207,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_log.DebugFormat( "[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures", - successfulAssetRestores, failedAssetRestores); + m_successfulAssetRestores, m_failedAssetRestores); m_log.InfoFormat("[INVENTORY ARCHIVER]: Successfully loaded {0} items", successfulItemRestores); return loadedNodes; @@ -566,7 +544,40 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver majorVersion, MAX_MAJOR_VERSION)); } - m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version); + m_controlFileLoaded = true; + m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version); } + + /// + /// Load asset file + /// + /// + /// + protected void LoadAssetFile(string path, byte[] data) + { + if (!m_controlFileLoaded) + throw new Exception( + string.Format( + "The IAR you are trying to load does not list {0} before {1}. Aborting load", + ArchiveConstants.CONTROL_FILE_PATH, ArchiveConstants.ASSETS_PATH)); + + if (!m_inventoryNodesLoaded) + throw new Exception( + string.Format( + "The IAR you are trying to load does not list all {0} before {1}. Aborting load", + ArchiveConstants.INVENTORY_PATH, ArchiveConstants.ASSETS_PATH)); + + if (LoadAsset(path, data)) + m_successfulAssetRestores++; + else + m_failedAssetRestores++; + + if ((m_successfulAssetRestores) % 50 == 0) + m_log.DebugFormat( + "[INVENTORY ARCHIVER]: Loaded {0} assets...", + m_successfulAssetRestores); + + m_assetsLoaded = true; + } } } \ No newline at end of file -- cgit v1.1 From f6b638fec92596e0671d0484c3b63bd600ef38ea Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 12 Mar 2011 00:49:13 +0000 Subject: factor inventory file loading into its own method --- .../Archiver/InventoryArchiveReadRequest.cs | 137 ++++++++++++--------- 1 file changed, 80 insertions(+), 57 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index cf4ba91..9b98de3 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -77,18 +77,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// private Stream m_loadStream; - /// - /// Record the creator id that should be associated with an asset. This is used to adjust asset creator ids - /// after OSP resolution (since OSP creators are only stored in the item - /// - protected Dictionary m_creatorIdForAssetId = new Dictionary(); - protected bool m_controlFileLoaded; protected bool m_assetsLoaded; protected bool m_inventoryNodesLoaded; protected int m_successfulAssetRestores; protected int m_failedAssetRestores; + protected int m_successfulItemRestores; + + /// + /// Root destination folder for the IAR load. + /// + protected InventoryFolderBase m_rootDestinationFolder; + + /// + /// Inventory nodes loaded from the iar. + /// + protected HashSet m_loadedNodes = new HashSet(); + + /// + /// In order to load identically named folders, we need to keep track of the folders that we have already + /// resolved. + /// + Dictionary m_resolvedFolders = new Dictionary(); + + /// + /// Record the creator id that should be associated with an asset. This is used to adjust asset creator ids + /// after OSP resolution (since OSP creators are only stored in the item + /// + protected Dictionary m_creatorIdForAssetId = new Dictionary(); public InventoryArchiveReadRequest( Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge) @@ -114,6 +131,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// /// Execute the request /// + /// + /// Only call this once. To load another IAR, construct another request object. + /// /// /// A list of the inventory nodes loaded. If folders were loaded then only the root folders are /// returned @@ -124,9 +144,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver try { string filePath = "ERROR"; - int successfulItemRestores = 0; - - HashSet loadedNodes = new HashSet(); List folderCandidates = InventoryArchiveUtils.FindFolderByPath( @@ -137,16 +154,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // Possibly provide an option later on to automatically create this folder if it does not exist m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath); - return loadedNodes; + return m_loadedNodes; } - InventoryFolderBase rootDestinationFolder = folderCandidates[0]; + m_rootDestinationFolder = folderCandidates[0]; archive = new TarArchiveReader(m_loadStream); - - // In order to load identically named folders, we need to keep track of the folders that we have already - // resolved - Dictionary resolvedFolders = new Dictionary(); - byte[] data; TarArchiveReader.TarEntryType entryType; @@ -162,44 +174,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) { - if (!m_controlFileLoaded) - throw new Exception( - string.Format( - "The IAR you are trying to load does not list {0} before {1}. Aborting load", - ArchiveConstants.CONTROL_FILE_PATH, ArchiveConstants.INVENTORY_PATH)); - - if (m_assetsLoaded) - throw new Exception( - string.Format( - "The IAR you are trying to load does not list all {0} before {1}. Aborting load", - ArchiveConstants.INVENTORY_PATH, ArchiveConstants.ASSETS_PATH)); - - filePath = filePath.Substring(ArchiveConstants.INVENTORY_PATH.Length); - - // Trim off the file portion if we aren't already dealing with a directory path - if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) - filePath = filePath.Remove(filePath.LastIndexOf("/") + 1); - - InventoryFolderBase foundFolder - = ReplicateArchivePathToUserInventory( - filePath, rootDestinationFolder, resolvedFolders, loadedNodes); - - if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) - { - InventoryItemBase item = LoadItem(data, foundFolder); - - if (item != null) - { - successfulItemRestores++; - - // If we aren't loading the folder containing the item then well need to update the - // viewer separately for that item. - if (!loadedNodes.Contains(foundFolder)) - loadedNodes.Add(item); - } - } - - m_inventoryNodesLoaded = true; + LoadInventoryFile(filePath, entryType, data); } } @@ -208,9 +183,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_log.DebugFormat( "[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures", m_successfulAssetRestores, m_failedAssetRestores); - m_log.InfoFormat("[INVENTORY ARCHIVER]: Successfully loaded {0} items", successfulItemRestores); + m_log.InfoFormat("[INVENTORY ARCHIVER]: Successfully loaded {0} items", m_successfulItemRestores); - return loadedNodes; + return m_loadedNodes; } finally { @@ -549,6 +524,54 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } /// + /// Load inventory file + /// + /// + /// + /// + protected void LoadInventoryFile(string path, TarArchiveReader.TarEntryType entryType, byte[] data) + { + if (!m_controlFileLoaded) + throw new Exception( + string.Format( + "The IAR you are trying to load does not list {0} before {1}. Aborting load", + ArchiveConstants.CONTROL_FILE_PATH, ArchiveConstants.INVENTORY_PATH)); + + if (m_assetsLoaded) + throw new Exception( + string.Format( + "The IAR you are trying to load does not list all {0} before {1}. Aborting load", + ArchiveConstants.INVENTORY_PATH, ArchiveConstants.ASSETS_PATH)); + + path = path.Substring(ArchiveConstants.INVENTORY_PATH.Length); + + // Trim off the file portion if we aren't already dealing with a directory path + if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) + path = path.Remove(path.LastIndexOf("/") + 1); + + InventoryFolderBase foundFolder + = ReplicateArchivePathToUserInventory( + path, m_rootDestinationFolder, m_resolvedFolders, m_loadedNodes); + + if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) + { + InventoryItemBase item = LoadItem(data, foundFolder); + + if (item != null) + { + m_successfulItemRestores++; + + // If we aren't loading the folder containing the item then well need to update the + // viewer separately for that item. + if (!m_loadedNodes.Contains(foundFolder)) + m_loadedNodes.Add(item); + } + } + + m_inventoryNodesLoaded = true; + } + + /// /// Load asset file /// /// @@ -578,6 +601,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_successfulAssetRestores); m_assetsLoaded = true; - } + } } } \ No newline at end of file -- cgit v1.1