From f7205da1d9e9aacf07c6e8e65f68f03848f2cb04 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 19 Oct 2008 17:51:42 +0000 Subject: * move command line parsing code from inventory archive modules to opensim server * use default inventory archive name if none is given * other minor cleanups * this facility is not useable yet --- .../Archiver/InventoryArchiveReadRequest.cs | 23 ++++++++++--------- .../Archiver/InventoryArchiveWriteRequest.cs | 26 ++++++++++------------ 2 files changed, 24 insertions(+), 25 deletions(-) (limited to 'OpenSim/Region/Environment/Modules/Avatar') diff --git a/OpenSim/Region/Environment/Modules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 91763a7..79e00cd 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 195dade..017ebcc 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(); - } - } } -- cgit v1.1