diff options
author | Melanie | 2011-05-08 20:23:06 +0100 |
---|---|---|
committer | Melanie | 2011-05-08 20:23:06 +0100 |
commit | b451cc1ebb9e950bb93e790ab9e83aff30a47c61 (patch) | |
tree | c9fbe41be36cf791976f9e5afabd44f69b64e747 /OpenSim/Services | |
parent | Enable compressed (gzip) fatpack transfers. (diff) | |
parent | Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff) | |
download | opensim-SC_OLD-b451cc1ebb9e950bb93e790ab9e83aff30a47c61.zip opensim-SC_OLD-b451cc1ebb9e950bb93e790ab9e83aff30a47c61.tar.gz opensim-SC_OLD-b451cc1ebb9e950bb93e790ab9e83aff30a47c61.tar.bz2 opensim-SC_OLD-b451cc1ebb9e950bb93e790ab9e83aff30a47c61.tar.xz |
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Services')
-rw-r--r-- | OpenSim/Services/AssetService/AssetService.cs | 56 |
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 | ||
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; |
@@ -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 | { |