From cc5ccfb3151544212a51b18ee224951b9c4ad927 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 13 Nov 2008 22:53:49 +0000 Subject: make inventory item listing more robust. It turns out that a bad item (one that won't parse right) will prevent all other items in that folder to load when inventory is requested. This is very careful to no longer add inventory items that return as null to the hash table for getInventoryInFolder, as well as be more careful parsing UUIDs for fields that aren't marked not null in MySQL. The net result, you may see previously missing inventory items return after this checkin. Folders probably need to be hardened in the same way, but I'm out of time for today. --- OpenSim/Data/MySQL/MySQLInventoryData.cs | 36 +++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index f9583cf..755dbab 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -141,8 +141,13 @@ namespace OpenSim.Data.MySQL result.Parameters.AddWithValue("?uuid", folderID.ToString()); MySqlDataReader reader = result.ExecuteReader(); - while (reader.Read()) - items.Add(readInventoryItem(reader)); + while (reader.Read()) + { + // A null item (because something went wrong) breaks everything in the folder + InventoryItemBase item = readInventoryItem(reader); + if (item != null) + items.Add(item); + } reader.Close(); result.Dispose(); @@ -301,24 +306,36 @@ namespace OpenSim.Data.MySQL try { InventoryItemBase item = new InventoryItemBase(); - + // Be a bit safer in parsing these because the + // database doesn't enforce them to be not null, and + // the inventory still works if these are weird in the + // db + + UUID Owner = UUID.Zero; + UUID Creator = UUID.Zero; + UUID GroupID = UUID.Zero; + UUID.TryParse((string)reader["avatarID"], out Owner); + UUID.TryParse((string)reader["creatorID"], out Creator); + UUID.TryParse((string)reader["groupID"], out GroupID); + item.Owner = Owner; + item.Creator = Creator; + item.GroupID = GroupID; + + // Rest of the parsing. If these UUID's fail, we're dead anyway item.ID = new UUID((string) reader["inventoryID"]); item.AssetID = new UUID((string) reader["assetID"]); item.AssetType = (int) reader["assetType"]; item.Folder = new UUID((string) reader["parentFolderID"]); - item.Owner = new UUID((string) reader["avatarID"]); item.Name = (string) reader["inventoryName"]; item.Description = (string) reader["inventoryDescription"]; item.NextPermissions = (uint) reader["inventoryNextPermissions"]; item.CurrentPermissions = (uint) reader["inventoryCurrentPermissions"]; item.InvType = (int) reader["invType"]; - item.Creator = new UUID((string) reader["creatorID"]); item.BasePermissions = (uint) reader["inventoryBasePermissions"]; item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; item.SalePrice = (int) reader["salePrice"]; item.SaleType = Convert.ToByte(reader["saleType"]); item.CreationDate = (int) reader["creationDate"]; - item.GroupID = new UUID(reader["groupID"].ToString()); item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]); item.Flags = (uint) reader["flags"]; @@ -814,8 +831,11 @@ namespace OpenSim.Data.MySQL List list = new List(); while (result.Read()) - list.Add(readInventoryItem(result)); - + { + InventoryItemBase item = readInventoryItem(result); + if (item != null) + list.Add(item); + } return list; } catch (Exception e) -- cgit v1.1