aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/AssetService
diff options
context:
space:
mode:
authorMelanie2012-01-06 00:08:18 +0000
committerMelanie2012-01-06 00:08:18 +0000
commitfdfc4ab2a8e171139caf9751a23eb75afe881c2b (patch)
treebc0d8d3066ecf5fe87e0778e23190d14a58d3bc1 /OpenSim/Services/AssetService
parentThat needs to be callable from elsewhere! (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-fdfc4ab2a8e171139caf9751a23eb75afe881c2b.zip
opensim-SC_OLD-fdfc4ab2a8e171139caf9751a23eb75afe881c2b.tar.gz
opensim-SC_OLD-fdfc4ab2a8e171139caf9751a23eb75afe881c2b.tar.bz2
opensim-SC_OLD-fdfc4ab2a8e171139caf9751a23eb75afe881c2b.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs
Diffstat (limited to 'OpenSim/Services/AssetService')
-rw-r--r--OpenSim/Services/AssetService/AssetService.cs124
1 files changed, 3 insertions, 121 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;
32using Nini.Config; 32using Nini.Config;
33using log4net; 33using log4net;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Console;
36using OpenSim.Data; 35using OpenSim.Data;
37using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
38using OpenMetaverse; 37using 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