diff options
author | BlueWall | 2012-01-05 17:54:51 -0500 |
---|---|---|
committer | BlueWall | 2012-01-05 17:54:51 -0500 |
commit | f252161941f10e1d303b372b946945fb6b548019 (patch) | |
tree | 6037b7ddcb488dc17258f60cfb52756b86f718d6 /OpenSim/Services | |
parent | Merge branch 'new_modules' (diff) | |
parent | Add a "j2k decode" region console command that allows a manual request for a ... (diff) | |
download | opensim-SC_OLD-f252161941f10e1d303b372b946945fb6b548019.zip opensim-SC_OLD-f252161941f10e1d303b372b946945fb6b548019.tar.gz opensim-SC_OLD-f252161941f10e1d303b372b946945fb6b548019.tar.bz2 opensim-SC_OLD-f252161941f10e1d303b372b946945fb6b548019.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Services')
-rw-r--r-- | OpenSim/Services/AssetService/AssetService.cs | 124 | ||||
-rw-r--r-- | OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs | 45 |
2 files changed, 5 insertions, 164 deletions
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs index b3af8e3..4f4cbf6 100644 --- a/OpenSim/Services/AssetService/AssetService.cs +++ b/OpenSim/Services/AssetService/AssetService.cs | |||
@@ -32,7 +32,6 @@ using System.Reflection; | |||
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using log4net; | 33 | using log4net; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Console; | ||
36 | using OpenSim.Data; | 35 | using OpenSim.Data; |
37 | using OpenSim.Services.Interfaces; | 36 | using OpenSim.Services.Interfaces; |
38 | using OpenMetaverse; | 37 | using OpenMetaverse; |
@@ -53,23 +52,6 @@ namespace OpenSim.Services.AssetService | |||
53 | { | 52 | { |
54 | m_RootInstance = this; | 53 | m_RootInstance = this; |
55 | 54 | ||
56 | MainConsole.Instance.Commands.AddCommand("kfs", false, | ||
57 | "show digest", | ||
58 | "show digest <ID>", | ||
59 | "Show asset digest", HandleShowDigest); | ||
60 | |||
61 | MainConsole.Instance.Commands.AddCommand("kfs", false, | ||
62 | "delete asset", | ||
63 | "delete asset <ID>", | ||
64 | "Delete asset from database", HandleDeleteAsset); | ||
65 | |||
66 | MainConsole.Instance.Commands.AddCommand("kfs", false, | ||
67 | "dump asset", | ||
68 | "dump asset <ID>", | ||
69 | "Dump asset to a file", | ||
70 | "The filename is the same as the ID given.", | ||
71 | HandleDumpAsset); | ||
72 | |||
73 | if (m_AssetLoader != null) | 55 | if (m_AssetLoader != null) |
74 | { | 56 | { |
75 | IConfig assetConfig = config.Configs["AssetService"]; | 57 | IConfig assetConfig = config.Configs["AssetService"]; |
@@ -218,111 +200,11 @@ namespace OpenSim.Services.AssetService | |||
218 | return m_Database.Delete(id); | 200 | return m_Database.Delete(id); |
219 | } | 201 | } |
220 | else | 202 | else |
221 | m_log.DebugFormat("[ASSET SERVICE]: Request to delete asset {0}, but flags are not Maptile", id); | ||
222 | |||
223 | return false; | ||
224 | } | ||
225 | |||
226 | void HandleDumpAsset(string module, string[] args) | ||
227 | { | ||
228 | if (args.Length < 3) | ||
229 | { | ||
230 | MainConsole.Instance.Output("Usage is dump asset <ID>"); | ||
231 | return; | ||
232 | } | ||
233 | |||
234 | string rawAssetId = args[2]; | ||
235 | UUID assetId; | ||
236 | |||
237 | if (!UUID.TryParse(rawAssetId, out assetId)) | ||
238 | { | ||
239 | MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId); | ||
240 | return; | ||
241 | } | ||
242 | |||
243 | AssetBase asset = m_Database.GetAsset(assetId); | ||
244 | if (asset == null) | ||
245 | { | ||
246 | MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId); | ||
247 | return; | ||
248 | } | ||
249 | |||
250 | string fileName = rawAssetId; | ||
251 | |||
252 | using (FileStream fs = new FileStream(fileName, FileMode.CreateNew)) | ||
253 | { | ||
254 | using (BinaryWriter bw = new BinaryWriter(fs)) | ||
255 | { | ||
256 | bw.Write(asset.Data); | ||
257 | } | ||
258 | } | ||
259 | |||
260 | MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName); | ||
261 | } | ||
262 | |||
263 | void HandleShowDigest(string module, string[] args) | ||
264 | { | ||
265 | if (args.Length < 3) | ||
266 | { | ||
267 | MainConsole.Instance.Output("Syntax: show digest <ID>"); | ||
268 | return; | ||
269 | } | ||
270 | |||
271 | AssetBase asset = Get(args[2]); | ||
272 | |||
273 | if (asset == null || asset.Data.Length == 0) | ||
274 | { | ||
275 | MainConsole.Instance.Output("Asset not found"); | ||
276 | return; | ||
277 | } | ||
278 | |||
279 | int i; | ||
280 | |||
281 | MainConsole.Instance.OutputFormat("Name: {0}", asset.Name); | ||
282 | MainConsole.Instance.OutputFormat("Description: {0}", asset.Description); | ||
283 | MainConsole.Instance.OutputFormat("Type: {0} (type number = {1})", (AssetType)asset.Type, asset.Type); | ||
284 | MainConsole.Instance.OutputFormat("Content-type: {0}", asset.Metadata.ContentType); | ||
285 | MainConsole.Instance.OutputFormat("Flags: {0}", asset.Metadata.Flags); | ||
286 | |||
287 | for (i = 0 ; i < 5 ; i++) | ||
288 | { | 203 | { |
289 | int off = i * 16; | 204 | m_log.DebugFormat("[ASSET SERVICE]: Request to delete asset {0}, but flags are not Maptile", id); |
290 | if (asset.Data.Length <= off) | ||
291 | break; | ||
292 | int len = 16; | ||
293 | if (asset.Data.Length < off + len) | ||
294 | len = asset.Data.Length - off; | ||
295 | |||
296 | byte[] line = new byte[len]; | ||
297 | Array.Copy(asset.Data, off, line, 0, len); | ||
298 | |||
299 | string text = BitConverter.ToString(line); | ||
300 | MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text)); | ||
301 | } | ||
302 | } | ||
303 | |||
304 | void HandleDeleteAsset(string module, string[] args) | ||
305 | { | ||
306 | if (args.Length < 3) | ||
307 | { | ||
308 | MainConsole.Instance.Output("Syntax: delete asset <ID>"); | ||
309 | return; | ||
310 | } | ||
311 | |||
312 | AssetBase asset = Get(args[2]); | ||
313 | |||
314 | if (asset == null || asset.Data.Length == 0) | ||
315 | { | ||
316 | MainConsole.Instance.Output("Asset not found"); | ||
317 | return; | ||
318 | } | 205 | } |
319 | 206 | ||
320 | Delete(args[2]); | 207 | return false; |
321 | |||
322 | //MainConsole.Instance.Output("Asset deleted"); | ||
323 | // TODO: Implement this | ||
324 | |||
325 | MainConsole.Instance.Output("Asset deletion not supported by database"); | ||
326 | } | 208 | } |
327 | } | 209 | } |
328 | } | 210 | } \ No newline at end of file |
diff --git a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs index d7b2ff8..e4c3eaf 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs | |||
@@ -86,11 +86,8 @@ namespace OpenSim.Services.Connectors | |||
86 | m_log.Error("[ASSET CONNECTOR]: No Server URI named in section AssetService"); | 86 | m_log.Error("[ASSET CONNECTOR]: No Server URI named in section AssetService"); |
87 | throw new Exception("Asset connector init error"); | 87 | throw new Exception("Asset connector init error"); |
88 | } | 88 | } |
89 | m_ServerURI = serviceURI; | ||
90 | 89 | ||
91 | MainConsole.Instance.Commands.AddCommand("asset", false, "dump asset", | 90 | m_ServerURI = serviceURI; |
92 | "dump asset <id> <file>", | ||
93 | "dump one cached asset", HandleDumpAsset); | ||
94 | } | 91 | } |
95 | 92 | ||
96 | protected void SetCache(IImprovedAssetCache cache) | 93 | protected void SetCache(IImprovedAssetCache cache) |
@@ -328,43 +325,5 @@ namespace OpenSim.Services.Connectors | |||
328 | } | 325 | } |
329 | return false; | 326 | return false; |
330 | } | 327 | } |
331 | |||
332 | private void HandleDumpAsset(string module, string[] args) | ||
333 | { | ||
334 | if (args.Length != 4) | ||
335 | { | ||
336 | MainConsole.Instance.Output("Syntax: dump asset <id> <file>"); | ||
337 | return; | ||
338 | } | ||
339 | |||
340 | UUID assetID; | ||
341 | |||
342 | if (!UUID.TryParse(args[2], out assetID)) | ||
343 | { | ||
344 | MainConsole.Instance.Output("Invalid asset ID"); | ||
345 | return; | ||
346 | } | ||
347 | |||
348 | if (m_Cache == null) | ||
349 | { | ||
350 | MainConsole.Instance.Output("Instance uses no cache"); | ||
351 | return; | ||
352 | } | ||
353 | |||
354 | AssetBase asset = m_Cache.Get(assetID.ToString()); | ||
355 | |||
356 | if (asset == null) | ||
357 | { | ||
358 | MainConsole.Instance.Output("Asset not found in cache"); | ||
359 | return; | ||
360 | } | ||
361 | |||
362 | string fileName = args[3]; | ||
363 | |||
364 | FileStream fs = File.Create(fileName); | ||
365 | fs.Write(asset.Data, 0, asset.Data.Length); | ||
366 | |||
367 | fs.Close(); | ||
368 | } | ||
369 | } | 328 | } |
370 | } | 329 | } \ No newline at end of file |