diff options
author | Melanie | 2009-10-01 21:26:53 +0100 |
---|---|---|
committer | Melanie | 2009-10-01 21:29:57 +0100 |
commit | 7c1fdb25409cafdce17d24ae1b7262ae6dca3e8f (patch) | |
tree | 02083a4e517f3dcc831f5ec2c845e9c0665f7447 /OpenSim/Services/Connectors | |
parent | Add OnQueueEmpty event to the packet layers. No user functinality yet (diff) | |
download | opensim-SC_OLD-7c1fdb25409cafdce17d24ae1b7262ae6dca3e8f.zip opensim-SC_OLD-7c1fdb25409cafdce17d24ae1b7262ae6dca3e8f.tar.gz opensim-SC_OLD-7c1fdb25409cafdce17d24ae1b7262ae6dca3e8f.tar.bz2 opensim-SC_OLD-7c1fdb25409cafdce17d24ae1b7262ae6dca3e8f.tar.xz |
Add "dump asset" command to remote asset connector (the only one that uses a
cache at all)
Diffstat (limited to '')
-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 | } |