aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/AssetService/AssetService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/AssetService/AssetService.cs')
-rw-r--r--OpenSim/Services/AssetService/AssetService.cs42
1 files changed, 42 insertions, 0 deletions
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs
index e1f90b6..80d58e1 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,39 @@ 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 using (FileStream fs = new FileStream(rawAssetId, FileMode.CreateNew))
227 {
228 using (BinaryWriter bw = new BinaryWriter(fs))
229 {
230 bw.Write(asset.Data);
231 }
232 }
233 }
192 234
193 void HandleShowDigest(string module, string[] args) 235 void HandleShowDigest(string module, string[] args)
194 { 236 {