aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
authorMelanie2011-05-08 20:20:40 +0100
committerMelanie2011-05-08 20:20:40 +0100
commit1be67914fab348115faa1fc9e9ecffbf7c303093 (patch)
tree7ad4917efae6aebeefa51fe03b1d1aac3e95efcb /OpenSim/Services
parentEnable compressed (gzip) fatpack transfers. (diff)
parentMantis #5472 (diff)
downloadopensim-SC_OLD-1be67914fab348115faa1fc9e9ecffbf7c303093.zip
opensim-SC_OLD-1be67914fab348115faa1fc9e9ecffbf7c303093.tar.gz
opensim-SC_OLD-1be67914fab348115faa1fc9e9ecffbf7c303093.tar.bz2
opensim-SC_OLD-1be67914fab348115faa1fc9e9ecffbf7c303093.tar.xz
Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/AssetService/AssetService.cs56
1 files changed, 51 insertions, 5 deletions
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs
index e1f90b6..851b7b4 100644
--- a/OpenSim/Services/AssetService/AssetService.cs
+++ b/OpenSim/Services/AssetService/AssetService.cs
@@ -26,6 +26,8 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
30using System.IO;
29using System.Reflection; 31using System.Reflection;
30using Nini.Config; 32using Nini.Config;
31using log4net; 33using log4net;
@@ -60,6 +62,13 @@ namespace OpenSim.Services.AssetService
60 "delete asset", 62 "delete asset",
61 "delete asset <ID>", 63 "delete asset <ID>",
62 "Delete asset from database", HandleDeleteAsset); 64 "Delete asset from database", HandleDeleteAsset);
65
66 MainConsole.Instance.Commands.AddCommand("kfs", false,
67 "dump asset",
68 "dump asset <ID>",
69 "Dump asset to a file",
70 "The filename is the same as the ID given.",
71 HandleDumpAsset);
63 72
64 if (m_AssetLoader != null) 73 if (m_AssetLoader != null)
65 { 74 {
@@ -189,6 +198,43 @@ namespace OpenSim.Services.AssetService
189 198
190 return false; 199 return false;
191 } 200 }
201
202 void HandleDumpAsset(string module, string[] args)
203 {
204 if (args.Length < 3)
205 {
206 MainConsole.Instance.Output("Usage is dump asset <ID>");
207 return;
208 }
209
210 string rawAssetId = args[2];
211 UUID assetId;
212
213 if (!UUID.TryParse(rawAssetId, out assetId))
214 {
215 MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId);
216 return;
217 }
218
219 AssetBase asset = m_Database.GetAsset(assetId);
220 if (asset == null)
221 {
222 MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId);
223 return;
224 }
225
226 string fileName = rawAssetId;
227
228 using (FileStream fs = new FileStream(fileName, FileMode.CreateNew))
229 {
230 using (BinaryWriter bw = new BinaryWriter(fs))
231 {
232 bw.Write(asset.Data);
233 }
234 }
235
236 MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName);
237 }
192 238
193 void HandleShowDigest(string module, string[] args) 239 void HandleShowDigest(string module, string[] args)
194 { 240 {
@@ -208,11 +254,11 @@ namespace OpenSim.Services.AssetService
208 254
209 int i; 255 int i;
210 256
211 MainConsole.Instance.Output(String.Format("Name: {0}", asset.Name)); 257 MainConsole.Instance.OutputFormat("Name: {0}", asset.Name);
212 MainConsole.Instance.Output(String.Format("Description: {0}", asset.Description)); 258 MainConsole.Instance.OutputFormat("Description: {0}", asset.Description);
213 MainConsole.Instance.Output(String.Format("Type: {0}", asset.Type)); 259 MainConsole.Instance.OutputFormat("Type: {0} (type number = {1})", (AssetType)asset.Type, asset.Type);
214 MainConsole.Instance.Output(String.Format("Content-type: {0}", asset.Metadata.ContentType)); 260 MainConsole.Instance.OutputFormat("Content-type: {0}", asset.Metadata.ContentType);
215 MainConsole.Instance.Output(String.Format("Flags: {0}", asset.Metadata.Flags.ToString())); 261 MainConsole.Instance.OutputFormat("Flags: {0}", asset.Metadata.Flags);
216 262
217 for (i = 0 ; i < 5 ; i++) 263 for (i = 0 ; i < 5 ; i++)
218 { 264 {