Increment version number of a folder when an object it contains is deleted.

Not doing this was allowing the viewer inventory cache to become out of sync if an item was directly deleted.
integration
Justin Clark-Casey (justincc) 2012-11-06 22:39:54 +00:00
parent 236cc1f268
commit a8424490ae
1 changed files with 25 additions and 3 deletions

View File

@ -123,11 +123,24 @@ namespace OpenSim.Data.MySQL
{ {
} }
public override bool Delete(string field, string val)
{
XInventoryItem[] retrievedItems = Get(new string[] { field }, new string[] { val });
if (retrievedItems.Length == 0)
return false;
if (!base.Delete(field, val))
return false;
IncrementFolderVersion(retrievedItems[0].parentFolderID);
return true;
}
public bool MoveItem(string id, string newParent) public bool MoveItem(string id, string newParent)
{ {
using (MySqlCommand cmd = new MySqlCommand()) using (MySqlCommand cmd = new MySqlCommand())
{ {
cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm); cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm);
cmd.Parameters.AddWithValue("?ParentFolderID", newParent); cmd.Parameters.AddWithValue("?ParentFolderID", newParent);
cmd.Parameters.AddWithValue("?InventoryID", id); cmd.Parameters.AddWithValue("?InventoryID", id);
@ -184,6 +197,13 @@ namespace OpenSim.Data.MySQL
if (!base.Store(item)) if (!base.Store(item))
return false; return false;
IncrementFolderVersion(item.parentFolderID);
return true;
}
private bool IncrementFolderVersion(UUID folderID)
{
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{ {
dbcon.Open(); dbcon.Open();
@ -193,7 +213,7 @@ namespace OpenSim.Data.MySQL
cmd.Connection = dbcon; cmd.Connection = dbcon;
cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID"); cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID");
cmd.Parameters.AddWithValue("?folderID", item.parentFolderID.ToString()); cmd.Parameters.AddWithValue("?folderID", folderID.ToString());
try try
{ {
@ -205,8 +225,10 @@ namespace OpenSim.Data.MySQL
} }
cmd.Dispose(); cmd.Dispose();
} }
dbcon.Close(); dbcon.Close();
} }
return true; return true;
} }
} }