From 7c1fdb25409cafdce17d24ae1b7262ae6dca3e8f Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 1 Oct 2009 21:26:53 +0100 Subject: Add "dump asset" command to remote asset connector (the only one that uses a cache at all) --- .../Connectors/Asset/AssetServiceConnector.cs | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'OpenSim/Services/Connectors/Asset') 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; using System.Reflection; using Nini.Config; using OpenSim.Framework; +using OpenSim.Framework.Console; using OpenSim.Framework.Communications; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Services.Interfaces; +using OpenMetaverse; namespace OpenSim.Services.Connectors { @@ -79,6 +81,10 @@ namespace OpenSim.Services.Connectors throw new Exception("Asset connector init error"); } m_ServerURI = serviceURI; + + MainConsole.Instance.Commands.AddCommand("asset", false, "dump asset", + "dump asset ", + "dump one cached asset", HandleDumpAsset); } protected void SetCache(IImprovedAssetCache cache) @@ -264,5 +270,43 @@ namespace OpenSim.Services.Connectors } return false; } + + private void HandleDumpAsset(string module, string[] args) + { + if (args.Length != 4) + { + MainConsole.Instance.Output("Syntax: dump asset "); + return; + } + + UUID assetID; + + if (!UUID.TryParse(args[2], out assetID)) + { + MainConsole.Instance.Output("Invalid asset ID"); + return; + } + + if (m_Cache == null) + { + MainConsole.Instance.Output("Instance uses no cache"); + return; + } + + AssetBase asset = asset = m_Cache.Get(assetID.ToString()); + + if (asset == null) + { + MainConsole.Instance.Output("Asset not found in cache"); + return; + } + + string fileName = args[3]; + + FileStream fs = File.Create(fileName); + fs.Write(asset.Data, 0, asset.Data.Length); + + fs.Close(); + } } } -- cgit v1.1