Accidentally committed too early
Revert "Allow item links to be deleted even when other deletes and purges are disabled."
This reverts commit 491279f99a
.
bulletsim
parent
c562b9ef19
commit
6dcc87b1ad
|
@ -74,38 +74,9 @@ namespace OpenSim.Data
|
||||||
bool StoreFolder(XInventoryFolder folder);
|
bool StoreFolder(XInventoryFolder folder);
|
||||||
bool StoreItem(XInventoryItem item);
|
bool StoreItem(XInventoryItem item);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Delete folders where field == val
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="field"></param>
|
|
||||||
/// <param name="val"></param>
|
|
||||||
/// <returns>true if the delete was successful, false if it was not</returns>
|
|
||||||
bool DeleteFolders(string field, string val);
|
bool DeleteFolders(string field, string val);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Delete folders where field1 == val1, field2 == val2...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fields"></param>
|
|
||||||
/// <param name="vals"></param>
|
|
||||||
/// <returns>true if the delete was successful, false if it was not</returns>
|
|
||||||
bool DeleteFolders(string[] fields, string[] vals);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Delete items where field == val
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="field"></param>
|
|
||||||
/// <param name="val"></param>
|
|
||||||
/// <returns>true if the delete was successful, false if it was not</returns>
|
|
||||||
bool DeleteItems(string field, string val);
|
bool DeleteItems(string field, string val);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Delete items where field1 == val1, field2 == val2...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fields"></param>
|
|
||||||
/// <param name="vals"></param>
|
|
||||||
/// <returns>true if the delete was successful, false if it was not</returns>
|
|
||||||
bool DeleteItems(string[] fields, string[] vals);
|
|
||||||
|
|
||||||
bool MoveItem(string id, string newParent);
|
bool MoveItem(string id, string newParent);
|
||||||
XInventoryItem[] GetActiveGestures(UUID principalID);
|
XInventoryItem[] GetActiveGestures(UUID principalID);
|
||||||
int GetAssetPermissions(UUID principalID, UUID assetID);
|
int GetAssetPermissions(UUID principalID, UUID assetID);
|
||||||
|
|
|
@ -335,35 +335,24 @@ namespace OpenSim.Data.MSSQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool Delete(string field, string key)
|
public virtual bool Delete(string field, string val)
|
||||||
{
|
{
|
||||||
return Delete(new string[] { field }, new string[] { key });
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool Delete(string[] fields, string[] keys)
|
|
||||||
{
|
|
||||||
if (fields.Length != keys.Length)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
List<string> terms = new List<string>();
|
|
||||||
|
|
||||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||||
using (SqlCommand cmd = new SqlCommand())
|
using (SqlCommand cmd = new SqlCommand())
|
||||||
{
|
{
|
||||||
for (int i = 0; i < fields.Length; i++)
|
string deleteCommand = String.Format("DELETE FROM {0} WHERE [{1}] = @{1}", m_Realm, field);
|
||||||
{
|
cmd.CommandText = deleteCommand;
|
||||||
cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i]));
|
|
||||||
terms.Add("[" + fields[i] + "] = @" + fields[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
string where = String.Join(" AND ", terms.ToArray());
|
|
||||||
|
|
||||||
string query = String.Format("DELETE * FROM {0} WHERE {1}", m_Realm, where);
|
|
||||||
|
|
||||||
|
cmd.Parameters.Add(m_database.CreateParameter(field, val));
|
||||||
cmd.Connection = conn;
|
cmd.Connection = conn;
|
||||||
cmd.CommandText = query;
|
|
||||||
conn.Open();
|
conn.Open();
|
||||||
return cmd.ExecuteNonQuery() > 0;
|
|
||||||
|
if (cmd.ExecuteNonQuery() > 0)
|
||||||
|
{
|
||||||
|
//m_log.Warn("[MSSQLGenericTable]: " + deleteCommand);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,21 +79,11 @@ namespace OpenSim.Data.MSSQL
|
||||||
return m_Folders.Delete(field, val);
|
return m_Folders.Delete(field, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DeleteFolders(string[] fields, string[] vals)
|
|
||||||
{
|
|
||||||
return m_Folders.Delete(fields, vals);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool DeleteItems(string field, string val)
|
public bool DeleteItems(string field, string val)
|
||||||
{
|
{
|
||||||
return m_Items.Delete(field, val);
|
return m_Items.Delete(field, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DeleteItems(string[] fields, string[] vals)
|
|
||||||
{
|
|
||||||
return m_Items.Delete(fields, vals);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool MoveItem(string id, string newParent)
|
public bool MoveItem(string id, string newParent)
|
||||||
{
|
{
|
||||||
return m_Items.MoveItem(id, newParent);
|
return m_Items.MoveItem(id, newParent);
|
||||||
|
|
|
@ -264,33 +264,18 @@ namespace OpenSim.Data.MySQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool Delete(string field, string key)
|
public virtual bool Delete(string field, string val)
|
||||||
{
|
{
|
||||||
return Delete(new string[] { field }, new string[] { key });
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool Delete(string[] fields, string[] keys)
|
|
||||||
{
|
|
||||||
if (fields.Length != keys.Length)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
List<string> terms = new List<string>();
|
|
||||||
|
|
||||||
using (MySqlCommand cmd = new MySqlCommand())
|
using (MySqlCommand cmd = new MySqlCommand())
|
||||||
{
|
{
|
||||||
for (int i = 0 ; i < fields.Length ; i++)
|
|
||||||
{
|
|
||||||
cmd.Parameters.AddWithValue(fields[i], keys[i]);
|
|
||||||
terms.Add("`" + fields[i] + "` = ?" + fields[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
string where = String.Join(" and ", terms.ToArray());
|
cmd.CommandText = String.Format("delete from {0} where `{1}` = ?{1}", m_Realm, field);
|
||||||
|
cmd.Parameters.AddWithValue(field, val);
|
||||||
|
|
||||||
string query = String.Format("delete from {0} where {1}", m_Realm, where);
|
if (ExecuteNonQuery(cmd) > 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
cmd.CommandText = query;
|
return false;
|
||||||
|
|
||||||
return ExecuteNonQuery(cmd) > 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,21 +85,11 @@ namespace OpenSim.Data.MySQL
|
||||||
return m_Folders.Delete(field, val);
|
return m_Folders.Delete(field, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DeleteFolders(string[] fields, string[] vals)
|
|
||||||
{
|
|
||||||
return m_Folders.Delete(fields, vals);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool DeleteItems(string field, string val)
|
public bool DeleteItems(string field, string val)
|
||||||
{
|
{
|
||||||
return m_Items.Delete(field, val);
|
return m_Items.Delete(field, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DeleteItems(string[] fields, string[] vals)
|
|
||||||
{
|
|
||||||
return m_Items.Delete(fields, vals);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool MoveItem(string id, string newParent)
|
public bool MoveItem(string id, string newParent)
|
||||||
{
|
{
|
||||||
return m_Items.MoveItem(id, newParent);
|
return m_Items.MoveItem(id, newParent);
|
||||||
|
|
|
@ -258,33 +258,17 @@ namespace OpenSim.Data.SQLite
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool Delete(string field, string key)
|
public bool Delete(string field, string val)
|
||||||
{
|
{
|
||||||
return Delete(new string[] { field }, new string[] { key });
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Delete(string[] fields, string[] keys)
|
|
||||||
{
|
|
||||||
if (fields.Length != keys.Length)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
List<string> terms = new List<string>();
|
|
||||||
|
|
||||||
SqliteCommand cmd = new SqliteCommand();
|
SqliteCommand cmd = new SqliteCommand();
|
||||||
|
|
||||||
for (int i = 0 ; i < fields.Length ; i++)
|
cmd.CommandText = String.Format("delete from {0} where `{1}` = :{1}", m_Realm, field);
|
||||||
{
|
cmd.Parameters.Add(new SqliteParameter(field, val));
|
||||||
cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i]));
|
|
||||||
terms.Add("`" + fields[i] + "` = :" + fields[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
string where = String.Join(" and ", terms.ToArray());
|
if (ExecuteNonQuery(cmd, m_Connection) > 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
string query = String.Format("delete * from {0} where {1}", m_Realm, where);
|
return false;
|
||||||
|
|
||||||
cmd.CommandText = query;
|
|
||||||
|
|
||||||
return ExecuteNonQuery(cmd, m_Connection) > 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,21 +91,11 @@ namespace OpenSim.Data.SQLite
|
||||||
return m_Folders.Delete(field, val);
|
return m_Folders.Delete(field, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DeleteFolders(string[] fields, string[] vals)
|
|
||||||
{
|
|
||||||
return m_Folders.Delete(fields, vals);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool DeleteItems(string field, string val)
|
public bool DeleteItems(string field, string val)
|
||||||
{
|
{
|
||||||
return m_Items.Delete(field, val);
|
return m_Items.Delete(field, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DeleteItems(string[] fields, string[] vals)
|
|
||||||
{
|
|
||||||
return m_Items.Delete(fields, vals);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool MoveItem(string id, string newParent)
|
public bool MoveItem(string id, string newParent)
|
||||||
{
|
{
|
||||||
return m_Items.MoveItem(id, newParent);
|
return m_Items.MoveItem(id, newParent);
|
||||||
|
|
|
@ -411,30 +411,12 @@ namespace OpenSim.Services.InventoryService
|
||||||
public virtual bool DeleteItems(UUID principalID, List<UUID> itemIDs)
|
public virtual bool DeleteItems(UUID principalID, List<UUID> itemIDs)
|
||||||
{
|
{
|
||||||
if (!m_AllowDelete)
|
if (!m_AllowDelete)
|
||||||
{
|
return false;
|
||||||
// We must still allow links and links to folders to be deleted, otherwise they will build up
|
|
||||||
// in the player's inventory until they can no longer log in. Deletions of links due to code bugs or
|
|
||||||
// similar is inconvenient but on a par with accidental movement of items. The original item is never
|
|
||||||
// touched.
|
|
||||||
foreach (UUID id in itemIDs)
|
|
||||||
{
|
|
||||||
if (!m_Database.DeleteItems(
|
|
||||||
new string[] { "inventoryID", "assetType" },
|
|
||||||
new string[] { id.ToString(), ((sbyte)AssetType.Link).ToString() }));
|
|
||||||
{
|
|
||||||
m_Database.DeleteItems(
|
|
||||||
new string[] { "inventoryID", "assetType" },
|
|
||||||
new string[] { id.ToString(), ((sbyte)AssetType.LinkFolder).ToString() });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Just use the ID... *facepalms*
|
// Just use the ID... *facepalms*
|
||||||
//
|
//
|
||||||
foreach (UUID id in itemIDs)
|
foreach (UUID id in itemIDs)
|
||||||
m_Database.DeleteItems("inventoryID", id.ToString());
|
m_Database.DeleteItems("inventoryID", id.ToString());
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue