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/SQLite/SQLiteXInventoryData.cs | 30 ++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data/SQLite/SQLiteXInventoryData.cs') diff --git a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs index 1f36986..75f8c87 100644 --- a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs +++ b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs @@ -47,7 +47,7 @@ namespace OpenSim.Data.SQLite { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private SQLiteGenericTableHandler m_Folders; + private SqliteFolderHandler m_Folders; private SqliteItemHandler m_Items; public SQLiteXInventoryData(string conn, string realm) @@ -55,7 +55,7 @@ namespace OpenSim.Data.SQLite if (Util.IsWindows()) Util.LoadArchSpecificWindowsDll("sqlite3.dll"); - m_Folders = new SQLiteGenericTableHandler( + m_Folders = new SqliteFolderHandler( conn, "inventoryfolders", "XInventoryStore"); m_Items = new SqliteItemHandler( conn, "inventoryitems", String.Empty); @@ -114,6 +114,11 @@ namespace OpenSim.Data.SQLite 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); @@ -177,4 +182,23 @@ namespace OpenSim.Data.SQLite return perms; } } -} + + public class SqliteFolderHandler : SQLiteGenericTableHandler + { + public SqliteFolderHandler(string c, string t, string m) : + base(c, t, m) + { + } + + public bool MoveFolder(string id, string newParentFolderID) + { + SqliteCommand cmd = new SqliteCommand(); + + cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where folderID = :FolderID", m_Realm); + cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParentFolderID)); + cmd.Parameters.Add(new SqliteParameter(":FolderID", id)); + + return ExecuteNonQuery(cmd, m_Connection) == 0 ? false : true; + } + } +} \ No newline at end of file -- cgit v1.1