diff options
-rw-r--r-- | OpenSim/Services/AssetService/AssetService.cs | 43 |
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 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
29 | using System.Reflection; | 31 | using System.Reflection; |
30 | using Nini.Config; | 32 | using Nini.Config; |
31 | using log4net; | 33 | using log4net; |
34 | using NDesk.Options; | ||
32 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
33 | using OpenSim.Framework.Console; | 36 | using OpenSim.Framework.Console; |
34 | using OpenSim.Data; | 37 | using 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 | { |