From 5e4cad07eb2cac6671ca86ac19d01f6a882c827d Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 18 Feb 2009 19:26:10 +0000 Subject: * Make save iar behave properly if the nominated inventory path does not exist * load iar probably still fails for this --- .../Archiver/InventoryArchiveWriteRequest.cs | 14 +++++++++---- .../Inventory/Archiver/InventoryArchiverModule.cs | 24 ++++++++++++++++------ 2 files changed, 28 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index be700e9..1152a1e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -95,6 +95,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } catch (IOException e) { + m_saveStream.Close(); reportedException = e; succeeded = false; } @@ -104,9 +105,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver protected void saveInvItem(InventoryItemBase inventoryItem, string path) { - string filename - = string.Format("{0}{1}_{2}.xml", - path, inventoryItem.Name, inventoryItem.ID); + string filename = string.Format("{0}{1}_{2}.xml", path, inventoryItem.Name, inventoryItem.ID); StringWriter sw = new StringWriter(); XmlTextWriter writer = new XmlTextWriter(sw); writer.Formatting = Formatting.Indented; @@ -182,6 +181,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver List items = inventoryFolder.RequestListOfItems(); string newPath = path + inventoryFolder.Name + InventoryFolderImpl.PATH_DELIMITER; archive.AddDir(newPath); + foreach (InventoryFolderImpl folder in inventories) { saveInvDir(folder, newPath); @@ -192,6 +192,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } } + /// + /// Execute the inventory write request + /// public void Execute() { InventoryFolderImpl inventoryFolder = null; @@ -251,7 +254,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { if (null == inventoryItem) { - m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not find inventory entry at path {0}", m_invPath); + m_saveStream.Close(); + m_module.TriggerInventoryArchiveSaved( + false, m_userInfo, m_invPath, m_saveStream, + new Exception(string.Format("Could not find inventory entry at path {0}", m_invPath))); return; } else diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 1997562..f8a5d9f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -73,7 +73,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (m_scenes.Count == 0) { scene.RegisterModuleInterface(this); - CommsManager = scene.CommsManager; + CommsManager = scene.CommsManager; + OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted; scene.AddCommand( this, "load iar", @@ -207,11 +208,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver "[INVENTORY ARCHIVER]: Saving archive {0} from inventory path {1} for {2} {3}", savePath, invPath, firstName, lastName); - ArchiveInventory(firstName, lastName, invPath, savePath); - - m_log.InfoFormat( - "[INVENTORY ARCHIVER]: Saved archive {0} for {1} {2}", - savePath, firstName, lastName); + ArchiveInventory(firstName, lastName, invPath, savePath); + } + + private void SaveInvConsoleCommandCompleted( + bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, Exception reportedException) + { + if (succeeded) + { + m_log.InfoFormat("[INVENTORY ARCHIVER]: Saved archive for {0}", userInfo.UserProfile.Name); + } + else + { + m_log.ErrorFormat( + "[INVENTORY ARCHIVER]: Archive save for {0} failed - {1}", + userInfo.UserProfile.Name, reportedException.Message); + } } /// -- cgit v1.1