diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index eff24225d1..69bb4d8ccb 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -686,7 +686,7 @@ namespace OpenSim #endregion /// - /// Save inventory to a file. + /// Save inventory to a file archive /// /// protected void SaveInv(string[] cmdparams) @@ -697,11 +697,19 @@ namespace OpenSim m_log.Error("[CONSOLE]: usage is save-inv []"); return; } - new InventoryArchiveWriteRequest(m_sceneManager.CurrentOrFirstScene,m_commsManager).execute(cmdparams); + + string firstName = cmdparams[0]; + string lastName = cmdparams[1]; + string invPath = cmdparams[2]; + string savePath = (cmdparams.Length > 3 ? cmdparams[3] : DEFAULT_INV_BACKUP_FILENAME); + + new InventoryArchiveWriteRequest( + m_sceneManager.CurrentOrFirstScene,m_commsManager).execute( + firstName, lastName, invPath, savePath); } /// - /// Load inventory from a tar.gz file. + /// Load inventory from an inventory file archive /// /// protected void LoadInv(string[] cmdparams) @@ -712,7 +720,15 @@ namespace OpenSim m_log.Error("[CONSOLE]: usage is load-inv []"); return; } - new InventoryArchiveReadRequest(m_sceneManager.CurrentOrFirstScene, m_commsManager).execute(cmdparams); + + string firstName = cmdparams[0]; + string lastName = cmdparams[1]; + string invPath = cmdparams[2]; + string loadPath = (cmdparams.Length > 3 ? cmdparams[3] : DEFAULT_INV_BACKUP_FILENAME); + + new InventoryArchiveReadRequest( + m_sceneManager.CurrentOrFirstScene, m_commsManager).execute( + firstName, lastName, invPath, loadPath); } /// diff --git a/OpenSim/Region/Environment/Modules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 91763a7b3e..79e00cdea1 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -45,14 +45,15 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver { public class InventoryArchiveReadRequest { + private static ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + protected Scene scene; protected TarArchiveReader archive; private static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding(); - ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + CachedUserInfo userInfo; UserProfileData userProfile; CommunicationsManager commsManager; - string loadPath; public InventoryArchiveReadRequest(Scene currentScene, CommunicationsManager commsManager) { @@ -142,22 +143,17 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver return item; } - public void execute(string[] cmdparams) + public void execute(string firstName, string lastName, string invPath, string loadPath) { string filePath = "ERROR"; int successfulAssetRestores = 0; int failedAssetRestores = 0; - - string firstName = cmdparams[0]; - string lastName = cmdparams[1]; - //string invPath = cmdparams[2]; - loadPath = (cmdparams.Length > 3 ? cmdparams[3] : "inventory.tar.gz"); + int successfulItemRestores = 0; archive = new TarArchiveReader(new GZipStream( new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress)); - userProfile = commsManager.UserService.GetUserProfile(firstName, lastName); userInfo = commsManager.UserProfileCacheService.GetUserDetails(userProfile.ID); @@ -175,13 +171,18 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver { //Load the item InventoryItemBase item = loadInvItem(filePath, m_asciiEncoding.GetString(data)); - if (item != null) userInfo.AddItem(item); + if (item != null) + { + userInfo.AddItem(item); + successfulItemRestores++; + } } } archive.Close(); - m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores); + m_log.DebugFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores); + m_log.InfoFormat("[ARCHIVER]: Restored {0} items", successfulItemRestores); } /// diff --git a/OpenSim/Region/Environment/Modules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/Environment/Modules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 195dade678..017ebcc040 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -41,15 +41,20 @@ using log4net; namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver -{ +{ public class InventoryArchiveWriteRequest { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + protected Scene scene; protected TarArchiveWriter archive; protected CommunicationsManager commsManager; Dictionary assetUuids; - string savePath; - + + /// + /// The path to which the inventory archive will be saved. + /// + private string m_savePath; public InventoryArchiveWriteRequest(Scene currentScene, CommunicationsManager commsManager) { @@ -63,7 +68,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver { AssetsArchiver assetsArchiver = new AssetsArchiver(assetsFound); assetsArchiver.Archive(archive); - archive.WriteTar(new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress)); + archive.WriteTar(new GZipStream(new FileStream(m_savePath, FileMode.Create), CompressionMode.Compress)); } protected void saveInvItem(InventoryItemBase inventoryItem, string path) @@ -156,15 +161,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver } } - public void execute(string[] cmdparams) + public void execute(string firstName, string lastName, string invPath, string savePath) { - ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - string firstName = cmdparams[0]; - string lastName = cmdparams[1]; - string invPath = cmdparams[2]; - savePath = (cmdparams.Length > 3 ? cmdparams[3] : "inventory.tar.gz"); - + m_savePath = savePath; + UserProfileData userProfile = commsManager.UserService.GetUserProfile(firstName, lastName); if (null == userProfile) { @@ -242,8 +242,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver } new AssetsRequest(assetUuids.Keys, scene.AssetCache, ReceivedAllAssets).Execute(); - } - } }