From a8424490aea0c202cf95f0eac566a49d7670c691 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 6 Nov 2012 22:39:54 +0000 Subject: 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. --- OpenSim/Data/MySQL/MySQLXInventoryData.cs | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index caf18a4..189ee5e 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -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) { using (MySqlCommand cmd = new MySqlCommand()) { - cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm); cmd.Parameters.AddWithValue("?ParentFolderID", newParent); cmd.Parameters.AddWithValue("?InventoryID", id); @@ -184,6 +197,13 @@ namespace OpenSim.Data.MySQL if (!base.Store(item)) return false; + IncrementFolderVersion(item.parentFolderID); + + return true; + } + + private bool IncrementFolderVersion(UUID folderID) + { using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); @@ -193,7 +213,7 @@ namespace OpenSim.Data.MySQL cmd.Connection = dbcon; 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 { @@ -205,9 +225,11 @@ namespace OpenSim.Data.MySQL } cmd.Dispose(); } + dbcon.Close(); } + return true; } } -} +} \ No newline at end of file -- cgit v1.1 From bf469819a628dcb8df18d3e1fb6ff5ac77038f2d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 6 Nov 2012 23:44:52 +0000 Subject: Update folder version numbers when moving items and making the Delete(string[], string[]) call (not just string, string). This is to stop viewer inventory cache version numbers becoming out of sync with grid stored numbers when viewer performs these actions. If there are no problems with these changes, they will be propogated to SQLite (and MSSQL if that's simple enough). May also need to do the same on folder store/create/delete and maybe propogate version increments up the folder hierarchy, but that requires investigation. --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 6 +++ OpenSim/Data/MySQL/MySQLXInventoryData.cs | 51 ++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 4 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index da8e958..995c6a5 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -219,6 +219,8 @@ namespace OpenSim.Data.MySQL public virtual bool Store(T row) { +// m_log.DebugFormat("[MYSQL GENERIC TABLE HANDLER]: Store(T row) invoked"); + using (MySqlCommand cmd = new MySqlCommand()) { string query = ""; @@ -273,6 +275,10 @@ namespace OpenSim.Data.MySQL public virtual bool Delete(string[] fields, string[] keys) { +// m_log.DebugFormat( +// "[MYSQL GENERIC TABLE HANDLER]: Delete(string[] fields, string[] keys) invoked with {0}:{1}", +// string.Join(",", fields), string.Join(",", keys)); + if (fields.Length != keys.Length) return false; diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index 189ee5e..cccc500 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -26,9 +26,10 @@ */ using System; +using System.Collections.Generic; using System.Data; +using System.Linq; using System.Reflection; -using System.Collections.Generic; using log4net; using MySql.Data.MySqlClient; using OpenMetaverse; @@ -118,6 +119,8 @@ namespace OpenSim.Data.MySQL public class MySqlItemHandler : MySQLGenericTableHandler { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public MySqlItemHandler(string c, string t, string m) : base(c, t, m) { @@ -132,21 +135,53 @@ namespace OpenSim.Data.MySQL if (!base.Delete(field, val)) return false; - IncrementFolderVersion(retrievedItems[0].parentFolderID); + // Don't increment folder version here since Delete(string, string) calls Delete(string[], string[]) +// IncrementFolderVersion(retrievedItems[0].parentFolderID); + + return true; + } + + public override bool Delete(string[] fields, string[] vals) + { + XInventoryItem[] retrievedItems = Get(fields, vals); + if (retrievedItems.Length == 0) + return false; + + if (!base.Delete(fields, vals)) + return false; + + HashSet deletedItemFolderUUIDs = new HashSet(); + + Array.ForEach(retrievedItems, i => deletedItemFolderUUIDs.Add(i.parentFolderID)); + + foreach (UUID deletedItemFolderUUID in deletedItemFolderUUIDs) + IncrementFolderVersion(deletedItemFolderUUID); return true; } public bool MoveItem(string id, string newParent) { + XInventoryItem[] retrievedItems = Get(new string[] { "inventoryID" }, new string[] { id }); + if (retrievedItems.Length == 0) + return false; + + UUID oldParent = retrievedItems[0].parentFolderID; + using (MySqlCommand cmd = new MySqlCommand()) { cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm); cmd.Parameters.AddWithValue("?ParentFolderID", newParent); cmd.Parameters.AddWithValue("?InventoryID", id); - return ExecuteNonQuery(cmd) == 0 ? false : true; + if (ExecuteNonQuery(cmd) == 0) + return false; } + + IncrementFolderVersion(oldParent); + IncrementFolderVersion(newParent); + + return true; } public XInventoryItem[] GetActiveGestures(UUID principalID) @@ -204,6 +239,14 @@ namespace OpenSim.Data.MySQL private bool IncrementFolderVersion(UUID folderID) { + return IncrementFolderVersion(folderID.ToString()); + } + + private bool IncrementFolderVersion(string folderID) + { +// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID); +// Util.PrintCallStack(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); @@ -213,7 +256,7 @@ namespace OpenSim.Data.MySQL cmd.Connection = dbcon; cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID"); - cmd.Parameters.AddWithValue("?folderID", folderID.ToString()); + cmd.Parameters.AddWithValue("?folderID", folderID); try { -- cgit v1.1 From 75c880a6f3631a527b532773a8a493309a96028e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 9 Nov 2012 00:59:18 +0000 Subject: Update parent inventory folder version numbers when folders are moved/created/deleted to match version numbers cached by viewers. This is done in the way that one would expect (e.g. moving a folder increments version number on both source and destination parent folders). This should hopefully improve viewer reuse of its cached inventory information. Currently MySQL only but will be implement for SQLite/MSSQL if there are no issues. --- OpenSim/Data/MySQL/MySQLXInventoryData.cs | 94 ++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index cccc500..7a3b5b4 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -42,12 +42,12 @@ namespace OpenSim.Data.MySQL /// public class MySQLXInventoryData : IXInventoryData { - private MySQLGenericTableHandler m_Folders; + private MySqlFolderHandler m_Folders; private MySqlItemHandler m_Items; public MySQLXInventoryData(string conn, string realm) { - m_Folders = new MySQLGenericTableHandler( + m_Folders = new MySqlFolderHandler( conn, "inventoryfolders", "InventoryStore"); m_Items = new MySqlItemHandler( conn, "inventoryitems", String.Empty); @@ -106,6 +106,11 @@ namespace OpenSim.Data.MySQL return m_Items.MoveItem(id, newParent); } + public bool MoveFolder(string id, string newParent) + { + return m_Folders.MoveFolder(id, newParent); + } + public XInventoryItem[] GetActiveGestures(UUID principalID) { return m_Items.GetActiveGestures(principalID); @@ -275,4 +280,89 @@ namespace OpenSim.Data.MySQL return true; } } + + public class MySqlFolderHandler : MySQLGenericTableHandler + { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public MySqlFolderHandler(string c, string t, string m) : + base(c, t, m) + { + } + + public bool MoveFolder(string id, string newParentFolderID) + { + XInventoryFolder[] folders = Get(new string[] { "folderID" }, new string[] { id }); + + if (folders.Length == 0) + return false; + + UUID oldParentFolderUUID = folders[0].parentFolderID; + + using (MySqlCommand cmd = new MySqlCommand()) + { + cmd.CommandText + = String.Format( + "update {0} set parentFolderID = ?ParentFolderID where folderID = ?folderID", m_Realm); + cmd.Parameters.AddWithValue("?ParentFolderID", newParentFolderID); + cmd.Parameters.AddWithValue("?folderID", id); + + if (ExecuteNonQuery(cmd) == 0) + return false; + } + + IncrementFolderVersion(oldParentFolderUUID); + IncrementFolderVersion(newParentFolderID); + + return true; + } + + public override bool Store(XInventoryFolder folder) + { + if (!base.Store(folder)) + return false; + + IncrementFolderVersion(folder.parentFolderID); + + return true; + } + + private bool IncrementFolderVersion(UUID folderID) + { + return IncrementFolderVersion(folderID.ToString()); + } + + private bool IncrementFolderVersion(string folderID) + { +// m_log.DebugFormat("[MYSQL FOLDER HANDLER]: Incrementing version on folder {0}", folderID); +// Util.PrintCallStack(); + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = new MySqlCommand()) + { + cmd.Connection = dbcon; + + cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID"); + cmd.Parameters.AddWithValue("?folderID", folderID); + + try + { + cmd.ExecuteNonQuery(); + } + catch (Exception) + { + return false; + } + cmd.Dispose(); + } + + dbcon.Close(); + } + + return true; + } + } } \ No newline at end of file -- cgit v1.1 From e4cb7af98a122773e84baf9be38b8b34f02e89a4 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 13 Nov 2012 19:26:43 -0800 Subject: Updated all existing AssemblyVersions's to 0.7.5.*. Many DLLs still don't have an AssemblyInfo file. --- OpenSim/Data/MySQL/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs index c28829c..ab3fe36 100644 --- a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("0.6.5.*")] +[assembly : AssemblyVersion("0.7.5.*")] [assembly : AssemblyFileVersion("0.6.5.0")] -- cgit v1.1 From 350cd58e5e52b88651035bcba19010807bff7870 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 15 Nov 2012 04:01:30 +0000 Subject: refactor: move common inventory folder version update code to parent class in mysql, mssql and sqlite database plugins --- OpenSim/Data/MySQL/MySQLXInventoryData.cs | 51 ++++++------------------------- 1 file changed, 9 insertions(+), 42 deletions(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index 7a3b5b4..c74033e 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -122,7 +122,7 @@ namespace OpenSim.Data.MySQL } } - public class MySqlItemHandler : MySQLGenericTableHandler + public class MySqlItemHandler : MySqlInventoryHandler { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -241,47 +241,9 @@ namespace OpenSim.Data.MySQL return true; } - - private bool IncrementFolderVersion(UUID folderID) - { - return IncrementFolderVersion(folderID.ToString()); - } - - private bool IncrementFolderVersion(string folderID) - { -// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID); -// Util.PrintCallStack(); - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = new MySqlCommand()) - { - cmd.Connection = dbcon; - - cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID"); - cmd.Parameters.AddWithValue("?folderID", folderID); - - try - { - cmd.ExecuteNonQuery(); - } - catch (Exception) - { - return false; - } - cmd.Dispose(); - } - - dbcon.Close(); - } - - return true; - } } - public class MySqlFolderHandler : MySQLGenericTableHandler + public class MySqlFolderHandler : MySqlInventoryHandler { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -326,13 +288,18 @@ namespace OpenSim.Data.MySQL return true; } + } + + public class MySqlInventoryHandler : MySQLGenericTableHandler where T: class, new() + { + public MySqlInventoryHandler(string c, string t, string m) : base(c, t, m) {} - private bool IncrementFolderVersion(UUID folderID) + protected bool IncrementFolderVersion(UUID folderID) { return IncrementFolderVersion(folderID.ToString()); } - private bool IncrementFolderVersion(string folderID) + protected bool IncrementFolderVersion(string folderID) { // m_log.DebugFormat("[MYSQL FOLDER HANDLER]: Incrementing version on folder {0}", folderID); // Util.PrintCallStack(); -- cgit v1.1