aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/AssetService/AssetService.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-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 acbd2b1..005051a 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 {
@@ -190,6 +199,43 @@ namespace OpenSim.Services.AssetService
190 199
191 return false; 200 return false;
192 } 201 }
202
203 void HandleDumpAsset(string module, string[] args)
204 {
205 if (args.Length < 3)
206 {
207 MainConsole.Instance.Output("Usage is dump asset <ID>");
208 return;
209 }
210
211 string rawAssetId = args[2];
212 UUID assetId;
213
214 if (!UUID.TryParse(rawAssetId, out assetId))
215 {
216 MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId);
217 return;
218 }
219
220 AssetBase asset = m_Database.GetAsset(assetId);
221 if (asset == null)
222 {
223 MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId);
224 return;
225 }
226
227 string fileName = rawAssetId;
228
229 using (FileStream fs = new FileStream(fileName, FileMode.CreateNew))
230 {
231 using (BinaryWriter bw = new BinaryWriter(fs))
232 {
233 bw.Write(asset.Data);
234 }
235 }
236
237 MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName);
238 }
193 239
194 void HandleShowDigest(string module, string[] args) 240 void HandleShowDigest(string module, string[] args)
195 { 241 {
@@ -209,11 +255,11 @@ namespace OpenSim.Services.AssetService
209 255
210 int i; 256 int i;
211 257
212 MainConsole.Instance.Output(String.Format("Name: {0}", asset.Name)); 258 MainConsole.Instance.OutputFormat("Name: {0}", asset.Name);
213 MainConsole.Instance.Output(String.Format("Description: {0}", asset.Description)); 259 MainConsole.Instance.OutputFormat("Description: {0}", asset.Description);
214 MainConsole.Instance.Output(String.Format("Type: {0}", asset.Type)); 260 MainConsole.Instance.OutputFormat("Type: {0} (type number = {1})", (AssetType)asset.Type, asset.Type);
215 MainConsole.Instance.Output(String.Format("Content-type: {0}", asset.Metadata.ContentType)); 261 MainConsole.Instance.OutputFormat("Content-type: {0}", asset.Metadata.ContentType);
216 MainConsole.Instance.Output(String.Format("Flags: {0}", asset.Metadata.Flags.ToString())); 262 MainConsole.Instance.OutputFormat("Flags: {0}", asset.Metadata.Flags);
217 263
218 for (i = 0 ; i < 5 ; i++) 264 for (i = 0 ; i < 5 ; i++)
219 { 265 {