diff options
Diffstat (limited to 'OpenSim/Services')
-rw-r--r-- | OpenSim/Services/AssetService/AssetService.cs | 124 | ||||
-rw-r--r-- | OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs | 39 |
2 files changed, 3 insertions, 160 deletions
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs index ec424c0..d4bfe8f 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"]; |
@@ -221,111 +203,11 @@ namespace OpenSim.Services.AssetService | |||
221 | return m_Database.Delete(id); | 203 | return m_Database.Delete(id); |
222 | } | 204 | } |
223 | else | 205 | else |
224 | m_log.DebugFormat("[ASSET SERVICE]: Request to delete asset {0}, but flags are not Maptile", id); | ||
225 | |||
226 | return false; | ||
227 | } | ||
228 | |||
229 | void HandleDumpAsset(string module, string[] args) | ||
230 | { | ||
231 | if (args.Length < 3) | ||
232 | { | ||
233 | MainConsole.Instance.Output("Usage is dump asset <ID>"); | ||
234 | return; | ||
235 | } | ||
236 | |||
237 | string rawAssetId = args[2]; | ||
238 | UUID assetId; | ||
239 | |||
240 | if (!UUID.TryParse(rawAssetId, out assetId)) | ||
241 | { | ||
242 | MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId); | ||
243 | return; | ||
244 | } | ||
245 | |||
246 | AssetBase asset = m_Database.GetAsset(assetId); | ||
247 | if (asset == null) | ||
248 | { | ||
249 | MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId); | ||
250 | return; | ||
251 | } | ||
252 | |||
253 | string fileName = rawAssetId; | ||
254 | |||
255 | using (FileStream fs = new FileStream(fileName, FileMode.CreateNew)) | ||
256 | { | ||
257 | using (BinaryWriter bw = new BinaryWriter(fs)) | ||
258 | { | ||
259 | bw.Write(asset.Data); | ||
260 | } | ||
261 | } | ||
262 | |||
263 | MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName); | ||
264 | } | ||
265 | |||
266 | void HandleShowDigest(string module, string[] args) | ||
267 | { | ||
268 | if (args.Length < 3) | ||
269 | { | ||
270 | MainConsole.Instance.Output("Syntax: show digest <ID>"); | ||
271 | return; | ||
272 | } | ||
273 | |||
274 | AssetBase asset = Get(args[2]); | ||
275 | |||
276 | if (asset == null || asset.Data.Length == 0) | ||
277 | { | ||
278 | MainConsole.Instance.Output("Asset not found"); | ||
279 | return; | ||
280 | } | ||
281 | |||
282 | int i; | ||
283 | |||
284 | MainConsole.Instance.OutputFormat("Name: {0}", asset.Name); | ||
285 | MainConsole.Instance.OutputFormat("Description: {0}", asset.Description); | ||
286 | MainConsole.Instance.OutputFormat("Type: {0} (type number = {1})", (AssetType)asset.Type, asset.Type); | ||
287 | MainConsole.Instance.OutputFormat("Content-type: {0}", asset.Metadata.ContentType); | ||
288 | MainConsole.Instance.OutputFormat("Flags: {0}", asset.Metadata.Flags); | ||
289 | |||
290 | for (i = 0 ; i < 5 ; i++) | ||
291 | { | 206 | { |
292 | int off = i * 16; | 207 | m_log.DebugFormat("[ASSET SERVICE]: Request to delete asset {0}, but flags are not Maptile", id); |
293 | if (asset.Data.Length <= off) | ||
294 | break; | ||
295 | int len = 16; | ||
296 | if (asset.Data.Length < off + len) | ||
297 | len = asset.Data.Length - off; | ||
298 | |||
299 | byte[] line = new byte[len]; | ||
300 | Array.Copy(asset.Data, off, line, 0, len); | ||
301 | |||
302 | string text = BitConverter.ToString(line); | ||
303 | MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text)); | ||
304 | } | ||
305 | } | ||
306 | |||
307 | void HandleDeleteAsset(string module, string[] args) | ||
308 | { | ||
309 | if (args.Length < 3) | ||
310 | { | ||
311 | MainConsole.Instance.Output("Syntax: delete asset <ID>"); | ||
312 | return; | ||
313 | } | ||
314 | |||
315 | AssetBase asset = Get(args[2]); | ||
316 | |||
317 | if (asset == null || asset.Data.Length == 0) | ||
318 | { | ||
319 | MainConsole.Instance.Output("Asset not found"); | ||
320 | return; | ||
321 | } | 208 | } |
322 | 209 | ||
323 | Delete(args[2]); | 210 | return false; |
324 | |||
325 | //MainConsole.Instance.Output("Asset deleted"); | ||
326 | // TODO: Implement this | ||
327 | |||
328 | MainConsole.Instance.Output("Asset deletion not supported by database"); | ||
329 | } | 211 | } |
330 | } | 212 | } |
331 | } | 213 | } \ No newline at end of file |
diff --git a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs index c3268d1..9bd04ed 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs | |||
@@ -89,7 +89,6 @@ namespace OpenSim.Services.Connectors | |||
89 | m_log.Error("[ASSET CONNECTOR]: No Server URI named in section AssetService"); | 89 | m_log.Error("[ASSET CONNECTOR]: No Server URI named in section AssetService"); |
90 | throw new Exception("Asset connector init error"); | 90 | throw new Exception("Asset connector init error"); |
91 | } | 91 | } |
92 | m_ServerURI = serviceURI; | ||
93 | 92 | ||
94 | MainConsole.Instance.Commands.AddCommand("asset", false, "dump asset", | 93 | MainConsole.Instance.Commands.AddCommand("asset", false, "dump asset", |
95 | "dump asset <id> <file>", | 94 | "dump asset <id> <file>", |
@@ -461,43 +460,5 @@ namespace OpenSim.Services.Connectors | |||
461 | } | 460 | } |
462 | return false; | 461 | return false; |
463 | } | 462 | } |
464 | |||
465 | private void HandleDumpAsset(string module, string[] args) | ||
466 | { | ||
467 | if (args.Length != 4) | ||
468 | { | ||
469 | MainConsole.Instance.Output("Syntax: dump asset <id> <file>"); | ||
470 | return; | ||
471 | } | ||
472 | |||
473 | UUID assetID; | ||
474 | |||
475 | if (!UUID.TryParse(args[2], out assetID)) | ||
476 | { | ||
477 | MainConsole.Instance.Output("Invalid asset ID"); | ||
478 | return; | ||
479 | } | ||
480 | |||
481 | if (m_Cache == null) | ||
482 | { | ||
483 | MainConsole.Instance.Output("Instance uses no cache"); | ||
484 | return; | ||
485 | } | ||
486 | |||
487 | AssetBase asset = m_Cache.Get(assetID.ToString()); | ||
488 | |||
489 | if (asset == null) | ||
490 | { | ||
491 | MainConsole.Instance.Output("Asset not found in cache"); | ||
492 | return; | ||
493 | } | ||
494 | |||
495 | string fileName = args[3]; | ||
496 | |||
497 | FileStream fs = File.Create(fileName); | ||
498 | fs.Write(asset.Data, 0, asset.Data.Length); | ||
499 | |||
500 | fs.Close(); | ||
501 | } | ||
502 | } | 463 | } |
503 | } | 464 | } |