diff options
author | Melanie | 2009-10-01 21:26:53 +0100 |
---|---|---|
committer | Melanie | 2009-10-01 21:26:53 +0100 |
commit | 26478ff6892ccb32741588a7854d23cd62a13716 (patch) | |
tree | d6aa14fcc8c179b5e7f85591d605e418dd6259a5 /OpenSim | |
parent | Catch and print exceptions in MessagingService, to diagnose mysterious disapp... (diff) | |
download | opensim-SC-26478ff6892ccb32741588a7854d23cd62a13716.zip opensim-SC-26478ff6892ccb32741588a7854d23cd62a13716.tar.gz opensim-SC-26478ff6892ccb32741588a7854d23cd62a13716.tar.bz2 opensim-SC-26478ff6892ccb32741588a7854d23cd62a13716.tar.xz |
Add "dump asset" command to remote asset connector (the only one that uses a
cache at all)
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs index ffc8e4c..d16112d 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs | |||
@@ -32,9 +32,11 @@ using System.IO; | |||
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using Nini.Config; | 33 | using Nini.Config; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Console; | ||
35 | using OpenSim.Framework.Communications; | 36 | using OpenSim.Framework.Communications; |
36 | using OpenSim.Framework.Servers.HttpServer; | 37 | using OpenSim.Framework.Servers.HttpServer; |
37 | using OpenSim.Services.Interfaces; | 38 | using OpenSim.Services.Interfaces; |
39 | using OpenMetaverse; | ||
38 | 40 | ||
39 | namespace OpenSim.Services.Connectors | 41 | namespace OpenSim.Services.Connectors |
40 | { | 42 | { |
@@ -79,6 +81,10 @@ namespace OpenSim.Services.Connectors | |||
79 | throw new Exception("Asset connector init error"); | 81 | throw new Exception("Asset connector init error"); |
80 | } | 82 | } |
81 | m_ServerURI = serviceURI; | 83 | m_ServerURI = serviceURI; |
84 | |||
85 | MainConsole.Instance.Commands.AddCommand("asset", false, "dump asset", | ||
86 | "dump asset <id> <file>", | ||
87 | "dump one cached asset", HandleDumpAsset); | ||
82 | } | 88 | } |
83 | 89 | ||
84 | protected void SetCache(IImprovedAssetCache cache) | 90 | protected void SetCache(IImprovedAssetCache cache) |
@@ -264,5 +270,43 @@ namespace OpenSim.Services.Connectors | |||
264 | } | 270 | } |
265 | return false; | 271 | return false; |
266 | } | 272 | } |
273 | |||
274 | private void HandleDumpAsset(string module, string[] args) | ||
275 | { | ||
276 | if (args.Length != 4) | ||
277 | { | ||
278 | MainConsole.Instance.Output("Syntax: dump asset <id> <file>"); | ||
279 | return; | ||
280 | } | ||
281 | |||
282 | UUID assetID; | ||
283 | |||
284 | if (!UUID.TryParse(args[2], out assetID)) | ||
285 | { | ||
286 | MainConsole.Instance.Output("Invalid asset ID"); | ||
287 | return; | ||
288 | } | ||
289 | |||
290 | if (m_Cache == null) | ||
291 | { | ||
292 | MainConsole.Instance.Output("Instance uses no cache"); | ||
293 | return; | ||
294 | } | ||
295 | |||
296 | AssetBase asset = asset = m_Cache.Get(assetID.ToString()); | ||
297 | |||
298 | if (asset == null) | ||
299 | { | ||
300 | MainConsole.Instance.Output("Asset not found in cache"); | ||
301 | return; | ||
302 | } | ||
303 | |||
304 | string fileName = args[3]; | ||
305 | |||
306 | FileStream fs = File.Create(fileName); | ||
307 | fs.Write(asset.Data, 0, asset.Data.Length); | ||
308 | |||
309 | fs.Close(); | ||
310 | } | ||
267 | } | 311 | } |
268 | } | 312 | } |