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.
0.6.1-post-fixes
Sean Dague 2008-11-13 22:53:49 +00:00
parent c268a3c84e
commit cc5ccfb315
1 changed files with 27 additions and 7 deletions

View File

@ -142,7 +142,12 @@ namespace OpenSim.Data.MySQL
MySqlDataReader reader = result.ExecuteReader();
while (reader.Read())
items.Add(readInventoryItem(reader));
{
// 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<InventoryItemBase> list = new List<InventoryItemBase>();
while (result.Read())
list.Add(readInventoryItem(result));
{
InventoryItemBase item = readInventoryItem(result);
if (item != null)
list.Add(item);
}
return list;
}
catch (Exception e)