diff options
author | Justin Clark-Casey (justincc) | 2011-05-17 21:49:38 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-05-17 22:31:16 +0100 |
commit | 491279f99afc65860d44765ee7829c7dd5e4e38e (patch) | |
tree | 3237395646d9fd92b2424df31bc8f6e8109c7f48 /OpenSim/Data/SQLite | |
parent | don't throw a null reference if an inventory link target doesn't exist when w... (diff) | |
download | opensim-SC-491279f99afc65860d44765ee7829c7dd5e4e38e.zip opensim-SC-491279f99afc65860d44765ee7829c7dd5e4e38e.tar.gz opensim-SC-491279f99afc65860d44765ee7829c7dd5e4e38e.tar.bz2 opensim-SC-491279f99afc65860d44765ee7829c7dd5e4e38e.tar.xz |
Allow item links to be deleted even when other deletes and purges are disabled.
If these links are not deleted, then they will build up in the player's inventory until they can no longer log in.
Accidental deletion of links due to bugs or other causes is potentially inconvenient but on a par with items being
accidentally moved. When a link is deleted, the target of the link is never touched.
This is a general solution that accounts for the use of links anywhere in the user's inventory.
Diffstat (limited to 'OpenSim/Data/SQLite')
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs | 28 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteXInventoryData.cs | 10 |
2 files changed, 32 insertions, 6 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs index 0d7b001..3fb2d3f 100644 --- a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs +++ b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs | |||
@@ -258,17 +258,33 @@ namespace OpenSim.Data.SQLite | |||
258 | return false; | 258 | return false; |
259 | } | 259 | } |
260 | 260 | ||
261 | public bool Delete(string field, string val) | 261 | public virtual bool Delete(string field, string key) |
262 | { | 262 | { |
263 | return Delete(new string[] { field }, new string[] { key }); | ||
264 | } | ||
265 | |||
266 | public bool Delete(string[] fields, string[] keys) | ||
267 | { | ||
268 | if (fields.Length != keys.Length) | ||
269 | return false; | ||
270 | |||
271 | List<string> terms = new List<string>(); | ||
272 | |||
263 | SqliteCommand cmd = new SqliteCommand(); | 273 | SqliteCommand cmd = new SqliteCommand(); |
264 | 274 | ||
265 | cmd.CommandText = String.Format("delete from {0} where `{1}` = :{1}", m_Realm, field); | 275 | for (int i = 0 ; i < fields.Length ; i++) |
266 | cmd.Parameters.Add(new SqliteParameter(field, val)); | 276 | { |
277 | cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i])); | ||
278 | terms.Add("`" + fields[i] + "` = :" + fields[i]); | ||
279 | } | ||
280 | |||
281 | string where = String.Join(" and ", terms.ToArray()); | ||
267 | 282 | ||
268 | if (ExecuteNonQuery(cmd, m_Connection) > 0) | 283 | string query = String.Format("delete * from {0} where {1}", m_Realm, where); |
269 | return true; | ||
270 | 284 | ||
271 | return false; | 285 | cmd.CommandText = query; |
286 | |||
287 | return ExecuteNonQuery(cmd, m_Connection) > 0; | ||
272 | } | 288 | } |
273 | } | 289 | } |
274 | } | 290 | } |
diff --git a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs index ccbd86e..02edc30 100644 --- a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs +++ b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs | |||
@@ -91,11 +91,21 @@ namespace OpenSim.Data.SQLite | |||
91 | return m_Folders.Delete(field, val); | 91 | return m_Folders.Delete(field, val); |
92 | } | 92 | } |
93 | 93 | ||
94 | public bool DeleteFolders(string[] fields, string[] vals) | ||
95 | { | ||
96 | return m_Folders.Delete(fields, vals); | ||
97 | } | ||
98 | |||
94 | public bool DeleteItems(string field, string val) | 99 | public bool DeleteItems(string field, string val) |
95 | { | 100 | { |
96 | return m_Items.Delete(field, val); | 101 | return m_Items.Delete(field, val); |
97 | } | 102 | } |
98 | 103 | ||
104 | public bool DeleteItems(string[] fields, string[] vals) | ||
105 | { | ||
106 | return m_Items.Delete(fields, vals); | ||
107 | } | ||
108 | |||
99 | public bool MoveItem(string id, string newParent) | 109 | public bool MoveItem(string id, string newParent) |
100 | { | 110 | { |
101 | return m_Items.MoveItem(id, newParent); | 111 | return m_Items.MoveItem(id, newParent); |