From 430cc0a24ae325373a51663ebd38cf5c8b6dbc35 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 9 Aug 2009 23:22:59 +0100 Subject: Add "show digest " console commdn to the ROBUST asset handler R.O.B.U.S.T.# show digest b8d3965a-ad78-bf43-699b-bff8eca6c975 Name: Terrain Dirt Description: Type: 0 Content-type: image/jp2 0000: FF-4F-FF-51-00-2F-00-00-00-00-00-80-00-00-00-80 --- OpenSim/Services/AssetService/AssetService.cs | 75 +++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'OpenSim/Services/AssetService') diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs index 01a3b3d..fe663eb 100644 --- a/OpenSim/Services/AssetService/AssetService.cs +++ b/OpenSim/Services/AssetService/AssetService.cs @@ -30,6 +30,7 @@ using System.Reflection; using Nini.Config; using log4net; using OpenSim.Framework; +using OpenSim.Framework.Console; using OpenSim.Data; using OpenSim.Services.Interfaces; using OpenMetaverse; @@ -44,6 +45,16 @@ namespace OpenSim.Services.AssetService public AssetService(IConfigSource config) : base(config) { + MainConsole.Instance.Commands.AddCommand("kfs", false, + "show digest", + "show digest ", + "Show asset digest", HandleShowDigest); + + MainConsole.Instance.Commands.AddCommand("kfs", false, + "delete asset", + "delete asset ", + "Delete asset from database", HandleDeleteAsset); + if (m_AssetLoader != null) { IConfig assetConfig = config.Configs["AssetService"]; @@ -132,5 +143,69 @@ namespace OpenSim.Services.AssetService { return false; } + + void HandleShowDigest(string module, string[] args) + { + if (args.Length < 3) + { + MainConsole.Instance.Output("Syntax: show digest "); + return; + } + + AssetBase asset = Get(args[2]); + + if (asset == null || asset.Data.Length == 0) + { + MainConsole.Instance.Output("Asset not found"); + return; + } + + int i; + + MainConsole.Instance.Output(String.Format("Name: {0}", asset.Name)); + MainConsole.Instance.Output(String.Format("Description: {0}", asset.Description)); + MainConsole.Instance.Output(String.Format("Type: {0}", asset.Type)); + MainConsole.Instance.Output(String.Format("Content-type: {0}", asset.Metadata.ContentType)); + + for (i = 0 ; i < 5 ; i++) + { + int off = i * 16; + if (asset.Data.Length <= off) + break; + int len = 16; + if (asset.Data.Length < off + len) + len = asset.Data.Length - off; + + byte[] line = new byte[len]; + Array.Copy(asset.Data, off, line, 0, len); + + string text = BitConverter.ToString(line); + MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text)); + } + } + + void HandleDeleteAsset(string module, string[] args) + { + if (args.Length < 3) + { + MainConsole.Instance.Output("Syntax: delete asset "); + return; + } + + AssetBase asset = Get(args[2]); + + if (asset == null || asset.Data.Length == 0) + { + MainConsole.Instance.Output("Asset not found"); + return; + } + + Delete(args[2]); + + //MainConsole.Instance.Output("Asset deleted"); + // TODO: Implement this + + MainConsole.Instance.Output("Asset deletion not supported by database"); + } } } -- cgit v1.1