aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL
diff options
context:
space:
mode:
authorSean Dague2008-11-13 22:53:49 +0000
committerSean Dague2008-11-13 22:53:49 +0000
commitcc5ccfb3151544212a51b18ee224951b9c4ad927 (patch)
tree43fb1cb8bf2b0b7206a4db6cb7487f6ce4c168ca /OpenSim/Data/MySQL
parentFrom: awebb@us.ibm.com (diff)
downloadopensim-SC_OLD-cc5ccfb3151544212a51b18ee224951b9c4ad927.zip
opensim-SC_OLD-cc5ccfb3151544212a51b18ee224951b9c4ad927.tar.gz
opensim-SC_OLD-cc5ccfb3151544212a51b18ee224951b9c4ad927.tar.bz2
opensim-SC_OLD-cc5ccfb3151544212a51b18ee224951b9c4ad927.tar.xz
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.
Diffstat (limited to 'OpenSim/Data/MySQL')
-rw-r--r--OpenSim/Data/MySQL/MySQLInventoryData.cs36
1 files changed, 28 insertions, 8 deletions
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
141 result.Parameters.AddWithValue("?uuid", folderID.ToString()); 141 result.Parameters.AddWithValue("?uuid", folderID.ToString());
142 MySqlDataReader reader = result.ExecuteReader(); 142 MySqlDataReader reader = result.ExecuteReader();
143 143
144 while (reader.Read()) 144 while (reader.Read())
145 items.Add(readInventoryItem(reader)); 145 {
146 // A null item (because something went wrong) breaks everything in the folder
147 InventoryItemBase item = readInventoryItem(reader);
148 if (item != null)
149 items.Add(item);
150 }
146 151
147 reader.Close(); 152 reader.Close();
148 result.Dispose(); 153 result.Dispose();
@@ -301,24 +306,36 @@ namespace OpenSim.Data.MySQL
301 try 306 try
302 { 307 {
303 InventoryItemBase item = new InventoryItemBase(); 308 InventoryItemBase item = new InventoryItemBase();
304 309 // Be a bit safer in parsing these because the
310 // database doesn't enforce them to be not null, and
311 // the inventory still works if these are weird in the
312 // db
313
314 UUID Owner = UUID.Zero;
315 UUID Creator = UUID.Zero;
316 UUID GroupID = UUID.Zero;
317 UUID.TryParse((string)reader["avatarID"], out Owner);
318 UUID.TryParse((string)reader["creatorID"], out Creator);
319 UUID.TryParse((string)reader["groupID"], out GroupID);
320 item.Owner = Owner;
321 item.Creator = Creator;
322 item.GroupID = GroupID;
323
324 // Rest of the parsing. If these UUID's fail, we're dead anyway
305 item.ID = new UUID((string) reader["inventoryID"]); 325 item.ID = new UUID((string) reader["inventoryID"]);
306 item.AssetID = new UUID((string) reader["assetID"]); 326 item.AssetID = new UUID((string) reader["assetID"]);
307 item.AssetType = (int) reader["assetType"]; 327 item.AssetType = (int) reader["assetType"];
308 item.Folder = new UUID((string) reader["parentFolderID"]); 328 item.Folder = new UUID((string) reader["parentFolderID"]);
309 item.Owner = new UUID((string) reader["avatarID"]);
310 item.Name = (string) reader["inventoryName"]; 329 item.Name = (string) reader["inventoryName"];
311 item.Description = (string) reader["inventoryDescription"]; 330 item.Description = (string) reader["inventoryDescription"];
312 item.NextPermissions = (uint) reader["inventoryNextPermissions"]; 331 item.NextPermissions = (uint) reader["inventoryNextPermissions"];
313 item.CurrentPermissions = (uint) reader["inventoryCurrentPermissions"]; 332 item.CurrentPermissions = (uint) reader["inventoryCurrentPermissions"];
314 item.InvType = (int) reader["invType"]; 333 item.InvType = (int) reader["invType"];
315 item.Creator = new UUID((string) reader["creatorID"]);
316 item.BasePermissions = (uint) reader["inventoryBasePermissions"]; 334 item.BasePermissions = (uint) reader["inventoryBasePermissions"];
317 item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; 335 item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"];
318 item.SalePrice = (int) reader["salePrice"]; 336 item.SalePrice = (int) reader["salePrice"];
319 item.SaleType = Convert.ToByte(reader["saleType"]); 337 item.SaleType = Convert.ToByte(reader["saleType"]);
320 item.CreationDate = (int) reader["creationDate"]; 338 item.CreationDate = (int) reader["creationDate"];
321 item.GroupID = new UUID(reader["groupID"].ToString());
322 item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]); 339 item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]);
323 item.Flags = (uint) reader["flags"]; 340 item.Flags = (uint) reader["flags"];
324 341
@@ -814,8 +831,11 @@ namespace OpenSim.Data.MySQL
814 831
815 List<InventoryItemBase> list = new List<InventoryItemBase>(); 832 List<InventoryItemBase> list = new List<InventoryItemBase>();
816 while (result.Read()) 833 while (result.Read())
817 list.Add(readInventoryItem(result)); 834 {
818 835 InventoryItemBase item = readInventoryItem(result);
836 if (item != null)
837 list.Add(item);
838 }
819 return list; 839 return list;
820 } 840 }
821 catch (Exception e) 841 catch (Exception e)