diff options
Diffstat (limited to 'OpenSim/Services/AssetService/AssetService.cs')
-rw-r--r-- | OpenSim/Services/AssetService/AssetService.cs | 124 |
1 files changed, 3 insertions, 121 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 |