aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/AssetService/AssetService.cs
diff options
context:
space:
mode:
authorMelanie2009-08-09 23:22:59 +0100
committerMelanie2009-08-09 23:22:59 +0100
commit430cc0a24ae325373a51663ebd38cf5c8b6dbc35 (patch)
tree2e3a4766642646bd1f1109535d7e9583e48f6ffc /OpenSim/Services/AssetService/AssetService.cs
parentRe-removing 2 lines that got added back on Melanie's commits. git hickup. (diff)
downloadopensim-SC-430cc0a24ae325373a51663ebd38cf5c8b6dbc35.zip
opensim-SC-430cc0a24ae325373a51663ebd38cf5c8b6dbc35.tar.gz
opensim-SC-430cc0a24ae325373a51663ebd38cf5c8b6dbc35.tar.bz2
opensim-SC-430cc0a24ae325373a51663ebd38cf5c8b6dbc35.tar.xz
Add "show digest <id>" 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
Diffstat (limited to 'OpenSim/Services/AssetService/AssetService.cs')
-rw-r--r--OpenSim/Services/AssetService/AssetService.cs75
1 files changed, 75 insertions, 0 deletions
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;
30using Nini.Config; 30using Nini.Config;
31using log4net; 31using log4net;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Console;
33using OpenSim.Data; 34using OpenSim.Data;
34using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
35using OpenMetaverse; 36using OpenMetaverse;
@@ -44,6 +45,16 @@ namespace OpenSim.Services.AssetService
44 45
45 public AssetService(IConfigSource config) : base(config) 46 public AssetService(IConfigSource config) : base(config)
46 { 47 {
48 MainConsole.Instance.Commands.AddCommand("kfs", false,
49 "show digest",
50 "show digest <ID>",
51 "Show asset digest", HandleShowDigest);
52
53 MainConsole.Instance.Commands.AddCommand("kfs", false,
54 "delete asset",
55 "delete asset <ID>",
56 "Delete asset from database", HandleDeleteAsset);
57
47 if (m_AssetLoader != null) 58 if (m_AssetLoader != null)
48 { 59 {
49 IConfig assetConfig = config.Configs["AssetService"]; 60 IConfig assetConfig = config.Configs["AssetService"];
@@ -132,5 +143,69 @@ namespace OpenSim.Services.AssetService
132 { 143 {
133 return false; 144 return false;
134 } 145 }
146
147 void HandleShowDigest(string module, string[] args)
148 {
149 if (args.Length < 3)
150 {
151 MainConsole.Instance.Output("Syntax: show digest <ID>");
152 return;
153 }
154
155 AssetBase asset = Get(args[2]);
156
157 if (asset == null || asset.Data.Length == 0)
158 {
159 MainConsole.Instance.Output("Asset not found");
160 return;
161 }
162
163 int i;
164
165 MainConsole.Instance.Output(String.Format("Name: {0}", asset.Name));
166 MainConsole.Instance.Output(String.Format("Description: {0}", asset.Description));
167 MainConsole.Instance.Output(String.Format("Type: {0}", asset.Type));
168 MainConsole.Instance.Output(String.Format("Content-type: {0}", asset.Metadata.ContentType));
169
170 for (i = 0 ; i < 5 ; i++)
171 {
172 int off = i * 16;
173 if (asset.Data.Length <= off)
174 break;
175 int len = 16;
176 if (asset.Data.Length < off + len)
177 len = asset.Data.Length - off;
178
179 byte[] line = new byte[len];
180 Array.Copy(asset.Data, off, line, 0, len);
181
182 string text = BitConverter.ToString(line);
183 MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text));
184 }
185 }
186
187 void HandleDeleteAsset(string module, string[] args)
188 {
189 if (args.Length < 3)
190 {
191 MainConsole.Instance.Output("Syntax: delete asset <ID>");
192 return;
193 }
194
195 AssetBase asset = Get(args[2]);
196
197 if (asset == null || asset.Data.Length == 0)
198 {
199 MainConsole.Instance.Output("Asset not found");
200 return;
201 }
202
203 Delete(args[2]);
204
205 //MainConsole.Instance.Output("Asset deleted");
206 // TODO: Implement this
207
208 MainConsole.Instance.Output("Asset deletion not supported by database");
209 }
135 } 210 }
136} 211}