aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLGenericTableHandler.cs6
-rw-r--r--OpenSim/Data/MySQL/MySQLXInventoryData.cs51
2 files changed, 53 insertions, 4 deletions
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
219 219
220 public virtual bool Store(T row) 220 public virtual bool Store(T row)
221 { 221 {
222// m_log.DebugFormat("[MYSQL GENERIC TABLE HANDLER]: Store(T row) invoked");
223
222 using (MySqlCommand cmd = new MySqlCommand()) 224 using (MySqlCommand cmd = new MySqlCommand())
223 { 225 {
224 string query = ""; 226 string query = "";
@@ -273,6 +275,10 @@ namespace OpenSim.Data.MySQL
273 275
274 public virtual bool Delete(string[] fields, string[] keys) 276 public virtual bool Delete(string[] fields, string[] keys)
275 { 277 {
278// m_log.DebugFormat(
279// "[MYSQL GENERIC TABLE HANDLER]: Delete(string[] fields, string[] keys) invoked with {0}:{1}",
280// string.Join(",", fields), string.Join(",", keys));
281
276 if (fields.Length != keys.Length) 282 if (fields.Length != keys.Length)
277 return false; 283 return false;
278 284
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 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.Data; 30using System.Data;
31using System.Linq;
30using System.Reflection; 32using System.Reflection;
31using System.Collections.Generic;
32using log4net; 33using log4net;
33using MySql.Data.MySqlClient; 34using MySql.Data.MySqlClient;
34using OpenMetaverse; 35using OpenMetaverse;
@@ -118,6 +119,8 @@ namespace OpenSim.Data.MySQL
118 119
119 public class MySqlItemHandler : MySQLGenericTableHandler<XInventoryItem> 120 public class MySqlItemHandler : MySQLGenericTableHandler<XInventoryItem>
120 { 121 {
122// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
123
121 public MySqlItemHandler(string c, string t, string m) : 124 public MySqlItemHandler(string c, string t, string m) :
122 base(c, t, m) 125 base(c, t, m)
123 { 126 {
@@ -132,21 +135,53 @@ namespace OpenSim.Data.MySQL
132 if (!base.Delete(field, val)) 135 if (!base.Delete(field, val))
133 return false; 136 return false;
134 137
135 IncrementFolderVersion(retrievedItems[0].parentFolderID); 138 // Don't increment folder version here since Delete(string, string) calls Delete(string[], string[])
139// IncrementFolderVersion(retrievedItems[0].parentFolderID);
140
141 return true;
142 }
143
144 public override bool Delete(string[] fields, string[] vals)
145 {
146 XInventoryItem[] retrievedItems = Get(fields, vals);
147 if (retrievedItems.Length == 0)
148 return false;
149
150 if (!base.Delete(fields, vals))
151 return false;
152
153 HashSet<UUID> deletedItemFolderUUIDs = new HashSet<UUID>();
154
155 Array.ForEach<XInventoryItem>(retrievedItems, i => deletedItemFolderUUIDs.Add(i.parentFolderID));
156
157 foreach (UUID deletedItemFolderUUID in deletedItemFolderUUIDs)
158 IncrementFolderVersion(deletedItemFolderUUID);
136 159
137 return true; 160 return true;
138 } 161 }
139 162
140 public bool MoveItem(string id, string newParent) 163 public bool MoveItem(string id, string newParent)
141 { 164 {
165 XInventoryItem[] retrievedItems = Get(new string[] { "inventoryID" }, new string[] { id });
166 if (retrievedItems.Length == 0)
167 return false;
168
169 UUID oldParent = retrievedItems[0].parentFolderID;
170
142 using (MySqlCommand cmd = new MySqlCommand()) 171 using (MySqlCommand cmd = new MySqlCommand())
143 { 172 {
144 cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm); 173 cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm);
145 cmd.Parameters.AddWithValue("?ParentFolderID", newParent); 174 cmd.Parameters.AddWithValue("?ParentFolderID", newParent);
146 cmd.Parameters.AddWithValue("?InventoryID", id); 175 cmd.Parameters.AddWithValue("?InventoryID", id);
147 176
148 return ExecuteNonQuery(cmd) == 0 ? false : true; 177 if (ExecuteNonQuery(cmd) == 0)
178 return false;
149 } 179 }
180
181 IncrementFolderVersion(oldParent);
182 IncrementFolderVersion(newParent);
183
184 return true;
150 } 185 }
151 186
152 public XInventoryItem[] GetActiveGestures(UUID principalID) 187 public XInventoryItem[] GetActiveGestures(UUID principalID)
@@ -204,6 +239,14 @@ namespace OpenSim.Data.MySQL
204 239
205 private bool IncrementFolderVersion(UUID folderID) 240 private bool IncrementFolderVersion(UUID folderID)
206 { 241 {
242 return IncrementFolderVersion(folderID.ToString());
243 }
244
245 private bool IncrementFolderVersion(string folderID)
246 {
247// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
248// Util.PrintCallStack();
249
207 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 250 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
208 { 251 {
209 dbcon.Open(); 252 dbcon.Open();
@@ -213,7 +256,7 @@ namespace OpenSim.Data.MySQL
213 cmd.Connection = dbcon; 256 cmd.Connection = dbcon;
214 257
215 cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID"); 258 cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID");
216 cmd.Parameters.AddWithValue("?folderID", folderID.ToString()); 259 cmd.Parameters.AddWithValue("?folderID", folderID);
217 260
218 try 261 try
219 { 262 {