diff options
author | MW | 2007-08-10 13:59:19 +0000 |
---|---|---|
committer | MW | 2007-08-10 13:59:19 +0000 |
commit | 94c7e41ef1978a5be21e1a063c68ffc1c8a89b97 (patch) | |
tree | f40b2951bfbabe0bff2553355e3603450c737b0a /OpenSim/Region/Storage | |
parent | Couldn't leave this one alone. Data is now flowing both ways in (diff) | |
download | opensim-SC_OLD-94c7e41ef1978a5be21e1a063c68ffc1c8a89b97.zip opensim-SC_OLD-94c7e41ef1978a5be21e1a063c68ffc1c8a89b97.tar.gz opensim-SC_OLD-94c7e41ef1978a5be21e1a063c68ffc1c8a89b97.tar.bz2 opensim-SC_OLD-94c7e41ef1978a5be21e1a063c68ffc1c8a89b97.tar.xz |
Made a few changes so that once we enable the sqlite data store (simple line change in OpenSimMain), then basic ( with a few limits at moment) prim database backup will work.
Diffstat (limited to 'OpenSim/Region/Storage')
-rw-r--r-- | OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs index 66ca56d..18ff54d 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs | |||
@@ -1,6 +1,7 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using System.IO; | ||
4 | 5 | ||
5 | using OpenSim.Region.Environment.Scenes; | 6 | using OpenSim.Region.Environment.Scenes; |
6 | using OpenSim.Region.Environment.LandManagement; | 7 | using OpenSim.Region.Environment.LandManagement; |
@@ -8,11 +9,12 @@ using OpenSim.Region.Environment; | |||
8 | using OpenSim.Region.Interfaces; | 9 | using OpenSim.Region.Interfaces; |
9 | using OpenSim.Framework.Console; | 10 | using OpenSim.Framework.Console; |
10 | using OpenSim.Framework.Types; | 11 | using OpenSim.Framework.Types; |
12 | using OpenSim.Framework.Utilities; | ||
11 | using libsecondlife; | 13 | using libsecondlife; |
12 | 14 | ||
13 | using System.Data; | 15 | using System.Data; |
14 | using System.Data.SqlTypes; | 16 | using System.Data.SqlTypes; |
15 | // Yes, this won't compile on MS, need to deal with that later | 17 | |
16 | using Mono.Data.SqliteClient; | 18 | using Mono.Data.SqliteClient; |
17 | 19 | ||
18 | namespace OpenSim.DataStore.MonoSqliteStorage | 20 | namespace OpenSim.DataStore.MonoSqliteStorage |
@@ -47,6 +49,7 @@ namespace OpenSim.DataStore.MonoSqliteStorage | |||
47 | // TODO: see if the linkage actually holds. | 49 | // TODO: see if the linkage actually holds. |
48 | // primDa.FillSchema(ds, SchemaType.Source, "PrimSchema"); | 50 | // primDa.FillSchema(ds, SchemaType.Source, "PrimSchema"); |
49 | primDa.Fill(ds, "prims"); | 51 | primDa.Fill(ds, "prims"); |
52 | shapeDa.Fill(ds, "primshapes"); | ||
50 | ds.AcceptChanges(); | 53 | ds.AcceptChanges(); |
51 | 54 | ||
52 | DataTable prims = ds.Tables["prims"]; | 55 | DataTable prims = ds.Tables["prims"]; |
@@ -54,7 +57,6 @@ namespace OpenSim.DataStore.MonoSqliteStorage | |||
54 | setupPrimCommands(primDa, conn); | 57 | setupPrimCommands(primDa, conn); |
55 | 58 | ||
56 | // shapeDa.FillSchema(ds, SchemaType.Source, "ShapeSchema"); | 59 | // shapeDa.FillSchema(ds, SchemaType.Source, "ShapeSchema"); |
57 | shapeDa.Fill(ds, "primshapes"); | ||
58 | DataTable shapes = ds.Tables["primshapes"]; | 60 | DataTable shapes = ds.Tables["primshapes"]; |
59 | shapes.PrimaryKey = new DataColumn[] { shapes.Columns["UUID"] }; | 61 | shapes.PrimaryKey = new DataColumn[] { shapes.Columns["UUID"] }; |
60 | setupShapeCommands(shapeDa, conn); | 62 | setupShapeCommands(shapeDa, conn); |
@@ -378,6 +380,11 @@ namespace OpenSim.DataStore.MonoSqliteStorage | |||
378 | // text TODO: this isn't right] = but I'm not sure the right | 380 | // text TODO: this isn't right] = but I'm not sure the right |
379 | // way to specify this as a blob atm | 381 | // way to specify this as a blob atm |
380 | // s.TextureEntry = (byte[])row["Texture"]; | 382 | // s.TextureEntry = (byte[])row["Texture"]; |
383 | |||
384 | //following hack will only save the default face texture, any other textures on other faces | ||
385 | //won't be saved or restored. | ||
386 | LLObject.TextureEntry texture = new LLObject.TextureEntry( new LLUUID((string)row["Texture"])); | ||
387 | s.TextureEntry = texture.ToBytes(); | ||
381 | return s; | 388 | return s; |
382 | } | 389 | } |
383 | 390 | ||
@@ -414,7 +421,15 @@ namespace OpenSim.DataStore.MonoSqliteStorage | |||
414 | row["ProfileHollow"] = s.ProfileHollow; | 421 | row["ProfileHollow"] = s.ProfileHollow; |
415 | // text TODO: this isn't right] = but I'm not sure the right | 422 | // text TODO: this isn't right] = but I'm not sure the right |
416 | // way to specify this as a blob atm | 423 | // way to specify this as a blob atm |
417 | row["Texture"] = s.TextureEntry; | 424 | |
425 | // And I couldn't work out how to save binary data either | ||
426 | // seems that the texture colum is being treated as a string in the Datarow | ||
427 | // if you do a .getType() on it, it returns string, while the other columns return correct type | ||
428 | //following hack will only save the default face texture, any other textures on other faces | ||
429 | //won't be saved or restored. | ||
430 | // MW[10-08-07] | ||
431 | LLObject.TextureEntry text = new LLObject.TextureEntry(s.TextureEntry, 0, s.TextureEntry.Length); | ||
432 | row["Texture"] = text.DefaultTexture.TextureID.ToStringHyphenated(); | ||
418 | 433 | ||
419 | } | 434 | } |
420 | 435 | ||
@@ -449,9 +464,10 @@ namespace OpenSim.DataStore.MonoSqliteStorage | |||
449 | addPrim(prim); | 464 | addPrim(prim); |
450 | } | 465 | } |
451 | 466 | ||
452 | MainLog.Instance.Verbose("Attempting to do update...."); | 467 | MainLog.Instance.Verbose("Attempting to do database update...."); |
453 | primDa.Update(ds, "prims"); | 468 | primDa.Update(ds, "prims"); |
454 | MainLog.Instance.Verbose("Dump of prims:", ds.GetXml()); | 469 | shapeDa.Update(ds, "primshapes"); |
470 | // MainLog.Instance.Verbose("Dump of prims:", ds.GetXml()); | ||
455 | } | 471 | } |
456 | 472 | ||
457 | public void RemoveObject(LLUUID obj) | 473 | public void RemoveObject(LLUUID obj) |
@@ -472,15 +488,23 @@ namespace OpenSim.DataStore.MonoSqliteStorage | |||
472 | SceneObjectGroup group = new SceneObjectGroup(); | 488 | SceneObjectGroup group = new SceneObjectGroup(); |
473 | SceneObjectPart prim = buildPrim(primRow); | 489 | SceneObjectPart prim = buildPrim(primRow); |
474 | DataRow shapeRow = shapes.Rows.Find(prim.UUID); | 490 | DataRow shapeRow = shapes.Rows.Find(prim.UUID); |
475 | if (shapeRow != null) { | 491 | if (shapeRow != null) |
492 | { | ||
476 | prim.Shape = buildShape(shapeRow); | 493 | prim.Shape = buildShape(shapeRow); |
477 | } | 494 | } |
478 | group.Children.Add(prim.UUID, prim); | 495 | else |
496 | { | ||
497 | Console.WriteLine("No shape found for prim in storage, so setting default box shape"); | ||
498 | prim.Shape = BoxShape.Default; | ||
499 | } | ||
500 | group.AddPart(prim); | ||
479 | // TODO: there are a couple of known issues to get this to work | 501 | // TODO: there are a couple of known issues to get this to work |
480 | // * While we can add Children, we can't set the root part (or | 502 | // * While we can add Children, we can't set the root part (or |
481 | // or even figure out which should be the root part) | 503 | // or even figure out which should be the root part) |
482 | // * region handle may need to be persisted, it isn't now | 504 | // * region handle may need to be persisted, it isn't now |
483 | // retvals.Add(group); | 505 | group.RootPart = prim; |
506 | |||
507 | retvals.Add(group); | ||
484 | } | 508 | } |
485 | 509 | ||
486 | MainLog.Instance.Verbose("DATASTORE", "Sqlite - LoadObjects found " + prims.Rows.Count + " objects"); | 510 | MainLog.Instance.Verbose("DATASTORE", "Sqlite - LoadObjects found " + prims.Rows.Count + " objects"); |
@@ -517,5 +541,14 @@ namespace OpenSim.DataStore.MonoSqliteStorage | |||
517 | { | 541 | { |
518 | // TODO: DataSet commit | 542 | // TODO: DataSet commit |
519 | } | 543 | } |
544 | |||
545 | private void SaveAssetToFile(string filename, byte[] data) | ||
546 | { | ||
547 | FileStream fs = File.Create(filename); | ||
548 | BinaryWriter bw = new BinaryWriter(fs); | ||
549 | bw.Write(data); | ||
550 | bw.Close(); | ||
551 | fs.Close(); | ||
552 | } | ||
520 | } | 553 | } |
521 | } | 554 | } |