From 7679617d5290d24c92b42043fc6d924d37620c89 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 29 Dec 2018 13:29:39 +0000 Subject: change DBGSuids a bit, let it return uuid.zero in more fail cases, not killing region --- OpenSim/Data/DBGuids.cs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'OpenSim/Data') 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 if ((id == null) || (id == DBNull.Value)) return UUID.Zero; - if (id.GetType() == typeof(Guid)) + Type idtype = id.GetType(); + + if (idtype == typeof(Guid)) return new UUID((Guid)id); - if (id.GetType() == typeof(byte[])) + if (id.GetType() == typeof(string)) { - if (((byte[])id).Length == 0) - return UUID.Zero; - else if (((byte[])id).Length == 16) - return new UUID((byte[])id, 0); + Guid gg; + if (Guid.TryParse((string)id, out gg)) + return new UUID(gg); + return UUID.Zero; } - else if (id.GetType() == typeof(string)) + + if (idtype == typeof(byte[])) { - if (((string)id).Length == 0) + if (((byte[])id).Length < 16) return UUID.Zero; - else if (((string)id).Length == 36) - return new UUID((string)id); + return new UUID((byte[])id, 0); } - throw new Exception("Failed to convert db value to UUID: " + id.ToString()); } } -- cgit v1.1