diff options
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLXInventoryData.cs')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLXInventoryData.cs | 75 |
1 files changed, 70 insertions, 5 deletions
diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index caf18a4..cccc500 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs | |||
@@ -26,9 +26,10 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.Data; | 30 | using System.Data; |
31 | using System.Linq; | ||
30 | using System.Reflection; | 32 | using System.Reflection; |
31 | using System.Collections.Generic; | ||
32 | using log4net; | 33 | using log4net; |
33 | using MySql.Data.MySqlClient; | 34 | using MySql.Data.MySqlClient; |
34 | using OpenMetaverse; | 35 | using OpenMetaverse; |
@@ -118,22 +119,69 @@ 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 | { |
124 | } | 127 | } |
125 | 128 | ||
129 | public override bool Delete(string field, string val) | ||
130 | { | ||
131 | XInventoryItem[] retrievedItems = Get(new string[] { field }, new string[] { val }); | ||
132 | if (retrievedItems.Length == 0) | ||
133 | return false; | ||
134 | |||
135 | if (!base.Delete(field, val)) | ||
136 | return false; | ||
137 | |||
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); | ||
159 | |||
160 | return true; | ||
161 | } | ||
162 | |||
126 | public bool MoveItem(string id, string newParent) | 163 | public bool MoveItem(string id, string newParent) |
127 | { | 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 | |||
128 | using (MySqlCommand cmd = new MySqlCommand()) | 171 | using (MySqlCommand cmd = new MySqlCommand()) |
129 | { | 172 | { |
130 | |||
131 | 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); |
132 | cmd.Parameters.AddWithValue("?ParentFolderID", newParent); | 174 | cmd.Parameters.AddWithValue("?ParentFolderID", newParent); |
133 | cmd.Parameters.AddWithValue("?InventoryID", id); | 175 | cmd.Parameters.AddWithValue("?InventoryID", id); |
134 | 176 | ||
135 | return ExecuteNonQuery(cmd) == 0 ? false : true; | 177 | if (ExecuteNonQuery(cmd) == 0) |
178 | return false; | ||
136 | } | 179 | } |
180 | |||
181 | IncrementFolderVersion(oldParent); | ||
182 | IncrementFolderVersion(newParent); | ||
183 | |||
184 | return true; | ||
137 | } | 185 | } |
138 | 186 | ||
139 | public XInventoryItem[] GetActiveGestures(UUID principalID) | 187 | public XInventoryItem[] GetActiveGestures(UUID principalID) |
@@ -184,6 +232,21 @@ namespace OpenSim.Data.MySQL | |||
184 | if (!base.Store(item)) | 232 | if (!base.Store(item)) |
185 | return false; | 233 | return false; |
186 | 234 | ||
235 | IncrementFolderVersion(item.parentFolderID); | ||
236 | |||
237 | return true; | ||
238 | } | ||
239 | |||
240 | private bool IncrementFolderVersion(UUID folderID) | ||
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 | |||
187 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 250 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
188 | { | 251 | { |
189 | dbcon.Open(); | 252 | dbcon.Open(); |
@@ -193,7 +256,7 @@ namespace OpenSim.Data.MySQL | |||
193 | cmd.Connection = dbcon; | 256 | cmd.Connection = dbcon; |
194 | 257 | ||
195 | 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"); |
196 | cmd.Parameters.AddWithValue("?folderID", item.parentFolderID.ToString()); | 259 | cmd.Parameters.AddWithValue("?folderID", folderID); |
197 | 260 | ||
198 | try | 261 | try |
199 | { | 262 | { |
@@ -205,9 +268,11 @@ namespace OpenSim.Data.MySQL | |||
205 | } | 268 | } |
206 | cmd.Dispose(); | 269 | cmd.Dispose(); |
207 | } | 270 | } |
271 | |||
208 | dbcon.Close(); | 272 | dbcon.Close(); |
209 | } | 273 | } |
274 | |||
210 | return true; | 275 | return true; |
211 | } | 276 | } |
212 | } | 277 | } |
213 | } | 278 | } \ No newline at end of file |