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(-) 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