aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Services/AssetService/AssetService.cs43
1 files changed, 43 insertions, 0 deletions
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs
index e1f90b6..25a91f2 100644
--- a/OpenSim/Services/AssetService/AssetService.cs
+++ b/OpenSim/Services/AssetService/AssetService.cs
@@ -26,9 +26,12 @@
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;
34using NDesk.Options;
32using OpenSim.Framework; 35using OpenSim.Framework;
33using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
34using OpenSim.Data; 37using OpenSim.Data;
@@ -60,6 +63,13 @@ namespace OpenSim.Services.AssetService
60 "delete asset", 63 "delete asset",
61 "delete asset <ID>", 64 "delete asset <ID>",
62 "Delete asset from database", HandleDeleteAsset); 65 "Delete asset from database", HandleDeleteAsset);
66
67 MainConsole.Instance.Commands.AddCommand("kfs", false,
68 "dump asset",
69 "dump asset <ID>",
70 "Dump asset to a file",
71 "The filename is the same as the ID given.",
72 HandleDumpAsset);
63 73
64 if (m_AssetLoader != null) 74 if (m_AssetLoader != null)
65 { 75 {
@@ -189,6 +199,39 @@ namespace OpenSim.Services.AssetService
189 199
190 return false; 200 return false;
191 } 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 using (FileStream fs = new FileStream(rawAssetId, FileMode.CreateNew))
228 {
229 using (BinaryWriter bw = new BinaryWriter(fs))
230 {
231 bw.Write(asset.Data);
232 }
233 }
234 }
192 235
193 void HandleShowDigest(string module, string[] args) 236 void HandleShowDigest(string module, string[] args)
194 { 237 {