diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index ab5f485660..cfefbe9d3b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -30,11 +30,11 @@ using System.Collections.Generic; using System.IO; using System.Reflection; using log4net; +using NDesk.Options; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; - using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; @@ -91,9 +91,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver scene.AddCommand( this, "load iar", - "load iar []", + "load iar []", + //"load iar [--merge] []", "Load user inventory archive (IAR).", - " is user's first name." + Environment.NewLine + //"--merge is an option which merges the loaded IAR with existing inventory folders where possible, rather than always creating new ones" + //+ " is user's first name." + Environment.NewLine + " is user's first name." + Environment.NewLine + " is user's last name." + Environment.NewLine + " is the path inside the user's inventory where the IAR should be loaded." + Environment.NewLine + " is the user's password." + Environment.NewLine @@ -133,8 +136,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (handlerInventoryArchiveSaved != null) handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException); } + + public bool ArchiveInventory( + Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream) + { + return ArchiveInventory(id, firstName, lastName, invPath, pass, saveStream, new Dictionary()); + } - public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream) + public bool ArchiveInventory( + Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream, + Dictionary options) { if (m_scenes.Count > 0) { @@ -172,7 +183,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver return false; } - public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string pass, string savePath) + public bool ArchiveInventory( + Guid id, string firstName, string lastName, string invPath, string pass, string savePath, + Dictionary options) { if (m_scenes.Count > 0) { @@ -209,8 +222,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver return false; } - + public bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, Stream loadStream) + { + return DearchiveInventory(firstName, lastName, invPath, pass, loadStream, new Dictionary()); + } + + public bool DearchiveInventory( + string firstName, string lastName, string invPath, string pass, Stream loadStream, + Dictionary options) { if (m_scenes.Count > 0) { @@ -252,7 +272,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver return false; } - public bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, string loadPath) + public bool DearchiveInventory( + string firstName, string lastName, string invPath, string pass, string loadPath, + Dictionary options) { if (m_scenes.Count > 0) { @@ -300,29 +322,34 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// protected void HandleLoadInvConsoleCommand(string module, string[] cmdparams) { - if (cmdparams.Length < 6) + m_log.Info("[INVENTORY ARCHIVER]: PLEASE NOTE THAT THIS FACILITY IS EXPERIMENTAL. BUG REPORTS WELCOME."); + + Dictionary options = new Dictionary(); + OptionSet optionSet = new OptionSet().Add("m|merge", delegate (string v) { options["merge"] = v != null; }); + + List mainParams = optionSet.Parse(cmdparams); + + if (mainParams.Count < 6) { m_log.Error( "[INVENTORY ARCHIVER]: usage is load iar []"); return; - } + } - m_log.Info("[INVENTORY ARCHIVER]: PLEASE NOTE THAT THIS FACILITY IS EXPERIMENTAL. BUG REPORTS WELCOME."); - - string firstName = cmdparams[2]; - string lastName = cmdparams[3]; - string invPath = cmdparams[4]; - string pass = cmdparams[5]; - string loadPath = (cmdparams.Length > 6 ? cmdparams[6] : DEFAULT_INV_BACKUP_FILENAME); + string firstName = mainParams[2]; + string lastName = mainParams[3]; + string invPath = mainParams[4]; + string pass = mainParams[5]; + string loadPath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME); m_log.InfoFormat( "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", loadPath, invPath, firstName, lastName); - if (DearchiveInventory(firstName, lastName, invPath, pass, loadPath)) + if (DearchiveInventory(firstName, lastName, invPath, pass, loadPath, options)) m_log.InfoFormat( "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", - loadPath, firstName, lastName); + loadPath, firstName, lastName); } /// @@ -351,7 +378,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver savePath, invPath, firstName, lastName); Guid id = Guid.NewGuid(); - ArchiveInventory(id, firstName, lastName, invPath, pass, savePath); + ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, new Dictionary()); lock (m_pendingConsoleSaves) m_pendingConsoleSaves.Add(id); diff --git a/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs b/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs index fbadd91b20..01066e6ab1 100644 --- a/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs @@ -26,6 +26,7 @@ */ using System; +using System.Collections.Generic; using System.IO; using OpenSim.Services.Interfaces; @@ -59,6 +60,20 @@ namespace OpenSim.Region.Framework.Interfaces /// The stream from which the inventory archive will be loaded /// true if the first stage of the operation succeeded, false otherwise bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, Stream loadStream); + + /// + /// Dearchive a user's inventory folder from the given stream + /// + /// + /// + /// The inventory path in which to place the loaded folders and items + /// The stream from which the inventory archive will be loaded + /// Dearchiving options. At the moment, the only option is ("merge", true). This merges + /// the loaded IAR with existing folders where possible. + /// true if the first stage of the operation succeeded, false otherwise + bool DearchiveInventory( + string firstName, string lastName, string invPath, string pass, Stream loadStream, + Dictionary options); /// /// Archive a user's inventory folder to the given stream @@ -70,5 +85,19 @@ namespace OpenSim.Region.Framework.Interfaces /// The stream to which the inventory archive will be saved /// true if the first stage of the operation succeeded, false otherwise bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream); + + /// + /// Archive a user's inventory folder to the given stream + /// + /// ID representing this request. This will later be returned in the save event + /// + /// + /// The inventory path from which the inventory should be saved. + /// The stream to which the inventory archive will be saved + /// Archiving options. Currently, there are none. + /// true if the first stage of the operation succeeded, false otherwise + bool ArchiveInventory( + Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream, + Dictionary options); } }