aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-11-06 22:39:54 +0000
committerJustin Clark-Casey (justincc)2012-11-06 23:40:33 +0000
commita8424490aea0c202cf95f0eac566a49d7670c691 (patch)
treeebcc271f7b07980db0862cc1a99b26fca5b3941e
parentChange user message on TeskInventoryAccepted to let the viewer format it (diff)
downloadopensim-SC_OLD-a8424490aea0c202cf95f0eac566a49d7670c691.zip
opensim-SC_OLD-a8424490aea0c202cf95f0eac566a49d7670c691.tar.gz
opensim-SC_OLD-a8424490aea0c202cf95f0eac566a49d7670c691.tar.bz2
opensim-SC_OLD-a8424490aea0c202cf95f0eac566a49d7670c691.tar.xz
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.
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLXInventoryData.cs28
1 files changed, 25 insertions, 3 deletions
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
123 { 123 {
124 } 124 }
125 125
126 public override bool Delete(string field, string val)
127 {
128 XInventoryItem[] retrievedItems = Get(new string[] { field }, new string[] { val });
129 if (retrievedItems.Length == 0)
130 return false;
131
132 if (!base.Delete(field, val))
133 return false;
134
135 IncrementFolderVersion(retrievedItems[0].parentFolderID);
136
137 return true;
138 }
139
126 public bool MoveItem(string id, string newParent) 140 public bool MoveItem(string id, string newParent)
127 { 141 {
128 using (MySqlCommand cmd = new MySqlCommand()) 142 using (MySqlCommand cmd = new MySqlCommand())
129 { 143 {
130
131 cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm); 144 cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm);
132 cmd.Parameters.AddWithValue("?ParentFolderID", newParent); 145 cmd.Parameters.AddWithValue("?ParentFolderID", newParent);
133 cmd.Parameters.AddWithValue("?InventoryID", id); 146 cmd.Parameters.AddWithValue("?InventoryID", id);
@@ -184,6 +197,13 @@ namespace OpenSim.Data.MySQL
184 if (!base.Store(item)) 197 if (!base.Store(item))
185 return false; 198 return false;
186 199
200 IncrementFolderVersion(item.parentFolderID);
201
202 return true;
203 }
204
205 private bool IncrementFolderVersion(UUID folderID)
206 {
187 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 207 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
188 { 208 {
189 dbcon.Open(); 209 dbcon.Open();
@@ -193,7 +213,7 @@ namespace OpenSim.Data.MySQL
193 cmd.Connection = dbcon; 213 cmd.Connection = dbcon;
194 214
195 cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID"); 215 cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID");
196 cmd.Parameters.AddWithValue("?folderID", item.parentFolderID.ToString()); 216 cmd.Parameters.AddWithValue("?folderID", folderID.ToString());
197 217
198 try 218 try
199 { 219 {
@@ -205,9 +225,11 @@ namespace OpenSim.Data.MySQL
205 } 225 }
206 cmd.Dispose(); 226 cmd.Dispose();
207 } 227 }
228
208 dbcon.Close(); 229 dbcon.Close();
209 } 230 }
231
210 return true; 232 return true;
211 } 233 }
212 } 234 }
213} 235} \ No newline at end of file