aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/DBGuids.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/DBGuids.cs23
1 files changed, 12 insertions, 11 deletions
diff --git a/OpenSim/Data/DBGuids.cs b/OpenSim/Data/DBGuids.cs
index 1a2bf41..ed0e7ca 100644
--- a/OpenSim/Data/DBGuids.cs
+++ b/OpenSim/Data/DBGuids.cs
@@ -47,24 +47,25 @@ namespace OpenSim.Data
47 if ((id == null) || (id == DBNull.Value)) 47 if ((id == null) || (id == DBNull.Value))
48 return UUID.Zero; 48 return UUID.Zero;
49 49
50 if (id.GetType() == typeof(Guid)) 50 Type idtype = id.GetType();
51
52 if (idtype == typeof(Guid))
51 return new UUID((Guid)id); 53 return new UUID((Guid)id);
52 54
53 if (id.GetType() == typeof(byte[])) 55 if (id.GetType() == typeof(string))
54 { 56 {
55 if (((byte[])id).Length == 0) 57 Guid gg;
56 return UUID.Zero; 58 if (Guid.TryParse((string)id, out gg))
57 else if (((byte[])id).Length == 16) 59 return new UUID(gg);
58 return new UUID((byte[])id, 0); 60 return UUID.Zero;
59 } 61 }
60 else if (id.GetType() == typeof(string)) 62
63 if (idtype == typeof(byte[]))
61 { 64 {
62 if (((string)id).Length == 0) 65 if (((byte[])id).Length < 16)
63 return UUID.Zero; 66 return UUID.Zero;
64 else if (((string)id).Length == 36) 67 return new UUID((byte[])id, 0);
65 return new UUID((string)id);
66 } 68 }
67
68 throw new Exception("Failed to convert db value to UUID: " + id.ToString()); 69 throw new Exception("Failed to convert db value to UUID: " + id.ToString());
69 } 70 }
70 } 71 }