aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-10-19 17:51:42 +0000
committerJustin Clarke Casey2008-10-19 17:51:42 +0000
commitf7205da1d9e9aacf07c6e8e65f68f03848f2cb04 (patch)
treef60a02578aca207bcd6d95e034fdc790dcef9ac9 /OpenSim
parent* Fixed UDP server (again) (diff)
downloadopensim-SC_OLD-f7205da1d9e9aacf07c6e8e65f68f03848f2cb04.zip
opensim-SC_OLD-f7205da1d9e9aacf07c6e8e65f68f03848f2cb04.tar.gz
opensim-SC_OLD-f7205da1d9e9aacf07c6e8e65f68f03848f2cb04.tar.bz2
opensim-SC_OLD-f7205da1d9e9aacf07c6e8e65f68f03848f2cb04.tar.xz
* 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
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs24
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs23
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs26
3 files changed, 44 insertions, 29 deletions
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index eff2422..69bb4d8 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -686,7 +686,7 @@ namespace OpenSim
686 #endregion 686 #endregion
687 687
688 /// <summary> 688 /// <summary>
689 /// Save inventory to a file. 689 /// Save inventory to a file archive
690 /// </summary> 690 /// </summary>
691 /// <param name="cmdparams"></param> 691 /// <param name="cmdparams"></param>
692 protected void SaveInv(string[] cmdparams) 692 protected void SaveInv(string[] cmdparams)
@@ -697,11 +697,19 @@ namespace OpenSim
697 m_log.Error("[CONSOLE]: usage is save-inv <first name> <last name> <inventory path> [<save file path>]"); 697 m_log.Error("[CONSOLE]: usage is save-inv <first name> <last name> <inventory path> [<save file path>]");
698 return; 698 return;
699 } 699 }
700 new InventoryArchiveWriteRequest(m_sceneManager.CurrentOrFirstScene,m_commsManager).execute(cmdparams); 700
701 string firstName = cmdparams[0];
702 string lastName = cmdparams[1];
703 string invPath = cmdparams[2];
704 string savePath = (cmdparams.Length > 3 ? cmdparams[3] : DEFAULT_INV_BACKUP_FILENAME);
705
706 new InventoryArchiveWriteRequest(
707 m_sceneManager.CurrentOrFirstScene,m_commsManager).execute(
708 firstName, lastName, invPath, savePath);
701 } 709 }
702 710
703 /// <summary> 711 /// <summary>
704 /// Load inventory from a tar.gz file. 712 /// Load inventory from an inventory file archive
705 /// </summary> 713 /// </summary>
706 /// <param name="cmdparams"></param> 714 /// <param name="cmdparams"></param>
707 protected void LoadInv(string[] cmdparams) 715 protected void LoadInv(string[] cmdparams)
@@ -712,7 +720,15 @@ namespace OpenSim
712 m_log.Error("[CONSOLE]: usage is load-inv <first name> <last name> <inventory path> [<load file path>]"); 720 m_log.Error("[CONSOLE]: usage is load-inv <first name> <last name> <inventory path> [<load file path>]");
713 return; 721 return;
714 } 722 }
715 new InventoryArchiveReadRequest(m_sceneManager.CurrentOrFirstScene, m_commsManager).execute(cmdparams); 723
724 string firstName = cmdparams[0];
725 string lastName = cmdparams[1];
726 string invPath = cmdparams[2];
727 string loadPath = (cmdparams.Length > 3 ? cmdparams[3] : DEFAULT_INV_BACKUP_FILENAME);
728
729 new InventoryArchiveReadRequest(
730 m_sceneManager.CurrentOrFirstScene, m_commsManager).execute(
731 firstName, lastName, invPath, loadPath);
716 } 732 }
717 733
718 /// <summary> 734 /// <summary>
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
45{ 45{
46 public class InventoryArchiveReadRequest 46 public class InventoryArchiveReadRequest
47 { 47 {
48 private static ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49
48 protected Scene scene; 50 protected Scene scene;
49 protected TarArchiveReader archive; 51 protected TarArchiveReader archive;
50 private static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding(); 52 private static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding();
51 ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 53
52 CachedUserInfo userInfo; 54 CachedUserInfo userInfo;
53 UserProfileData userProfile; 55 UserProfileData userProfile;
54 CommunicationsManager commsManager; 56 CommunicationsManager commsManager;
55 string loadPath;
56 57
57 public InventoryArchiveReadRequest(Scene currentScene, CommunicationsManager commsManager) 58 public InventoryArchiveReadRequest(Scene currentScene, CommunicationsManager commsManager)
58 { 59 {
@@ -142,22 +143,17 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
142 return item; 143 return item;
143 } 144 }
144 145
145 public void execute(string[] cmdparams) 146 public void execute(string firstName, string lastName, string invPath, string loadPath)
146 { 147 {
147 string filePath = "ERROR"; 148 string filePath = "ERROR";
148 int successfulAssetRestores = 0; 149 int successfulAssetRestores = 0;
149 int failedAssetRestores = 0; 150 int failedAssetRestores = 0;
150 151 int successfulItemRestores = 0;
151 string firstName = cmdparams[0];
152 string lastName = cmdparams[1];
153 //string invPath = cmdparams[2];
154 loadPath = (cmdparams.Length > 3 ? cmdparams[3] : "inventory.tar.gz");
155 152
156 archive 153 archive
157 = new TarArchiveReader(new GZipStream( 154 = new TarArchiveReader(new GZipStream(
158 new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress)); 155 new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress));
159 156
160
161 userProfile = commsManager.UserService.GetUserProfile(firstName, lastName); 157 userProfile = commsManager.UserService.GetUserProfile(firstName, lastName);
162 userInfo = commsManager.UserProfileCacheService.GetUserDetails(userProfile.ID); 158 userInfo = commsManager.UserProfileCacheService.GetUserDetails(userProfile.ID);
163 159
@@ -175,13 +171,18 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
175 { 171 {
176 //Load the item 172 //Load the item
177 InventoryItemBase item = loadInvItem(filePath, m_asciiEncoding.GetString(data)); 173 InventoryItemBase item = loadInvItem(filePath, m_asciiEncoding.GetString(data));
178 if (item != null) userInfo.AddItem(item); 174 if (item != null)
175 {
176 userInfo.AddItem(item);
177 successfulItemRestores++;
178 }
179 } 179 }
180 } 180 }
181 181
182 archive.Close(); 182 archive.Close();
183 183
184 m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores); 184 m_log.DebugFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
185 m_log.InfoFormat("[ARCHIVER]: Restored {0} items", successfulItemRestores);
185 } 186 }
186 187
187 /// <summary> 188 /// <summary>
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;
41 41
42 42
43namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver 43namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
44{ 44{
45 public class InventoryArchiveWriteRequest 45 public class InventoryArchiveWriteRequest
46 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48
47 protected Scene scene; 49 protected Scene scene;
48 protected TarArchiveWriter archive; 50 protected TarArchiveWriter archive;
49 protected CommunicationsManager commsManager; 51 protected CommunicationsManager commsManager;
50 Dictionary<UUID, int> assetUuids; 52 Dictionary<UUID, int> assetUuids;
51 string savePath; 53
52 54 /// <value>
55 /// The path to which the inventory archive will be saved.
56 /// </value>
57 private string m_savePath;
53 58
54 public InventoryArchiveWriteRequest(Scene currentScene, CommunicationsManager commsManager) 59 public InventoryArchiveWriteRequest(Scene currentScene, CommunicationsManager commsManager)
55 { 60 {
@@ -63,7 +68,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
63 { 68 {
64 AssetsArchiver assetsArchiver = new AssetsArchiver(assetsFound); 69 AssetsArchiver assetsArchiver = new AssetsArchiver(assetsFound);
65 assetsArchiver.Archive(archive); 70 assetsArchiver.Archive(archive);
66 archive.WriteTar(new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress)); 71 archive.WriteTar(new GZipStream(new FileStream(m_savePath, FileMode.Create), CompressionMode.Compress));
67 } 72 }
68 73
69 protected void saveInvItem(InventoryItemBase inventoryItem, string path) 74 protected void saveInvItem(InventoryItemBase inventoryItem, string path)
@@ -156,15 +161,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
156 } 161 }
157 } 162 }
158 163
159 public void execute(string[] cmdparams) 164 public void execute(string firstName, string lastName, string invPath, string savePath)
160 { 165 {
161 ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 166 m_savePath = savePath;
162 167
163 string firstName = cmdparams[0];
164 string lastName = cmdparams[1];
165 string invPath = cmdparams[2];
166 savePath = (cmdparams.Length > 3 ? cmdparams[3] : "inventory.tar.gz");
167
168 UserProfileData userProfile = commsManager.UserService.GetUserProfile(firstName, lastName); 168 UserProfileData userProfile = commsManager.UserService.GetUserProfile(firstName, lastName);
169 if (null == userProfile) 169 if (null == userProfile)
170 { 170 {
@@ -242,8 +242,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
242 } 242 }
243 243
244 new AssetsRequest(assetUuids.Keys, scene.AssetCache, ReceivedAllAssets).Execute(); 244 new AssetsRequest(assetUuids.Keys, scene.AssetCache, ReceivedAllAssets).Execute();
245
246 } 245 }
247
248 } 246 }
249} 247}