diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index fc1a38f6a4..8db1073191 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -250,15 +250,16 @@ namespace OpenSim.Data.MySQL
///
/// The assets' IDs
/// For each asset: true if it exists, false otherwise
+
+ // caller needs to handle exceptions
public override bool[] AssetsExist(UUID[] uuids)
{
if (uuids.Length == 0)
return [];
- HashSet exist = new HashSet();
-
+ HashSet exist = [];
string ids = "'" + string.Join("','", uuids) + "'";
- string sql = string.Format("SELECT id FROM assets WHERE id IN ({0})", ids);
+ string sql = $"SELECT id FROM assets WHERE id IN ({ids})";
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
@@ -274,9 +275,7 @@ namespace OpenSim.Data.MySQL
}
}
}
- dbcon.Close();
}
-
bool[] results = new bool[uuids.Length];
for (int i = 0; i < uuids.Length; i++)
results[i] = exist.Contains(uuids[i]);
@@ -294,22 +293,20 @@ namespace OpenSim.Data.MySQL
/// A list of AssetMetadata objects.
public override List FetchAssetMetadataSet(int start, int count)
{
- List retList = new List(count);
-
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
+ List retList = new(count);
+ try
{
- dbcon.Open();
-
- using (MySqlCommand cmd
- = new MySqlCommand(
- "SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count",
- dbcon))
+ using (MySqlConnection dbcon = new(m_connectionString))
{
- cmd.Parameters.AddWithValue("?start", start);
- cmd.Parameters.AddWithValue("?count", count);
+ dbcon.Open();
- try
+ using (MySqlCommand cmd = new(
+ "SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count",
+ dbcon))
{
+ cmd.Parameters.AddWithValue("?start", start);
+ cmd.Parameters.AddWithValue("?count", count);
+
using (MySqlDataReader dbReader = cmd.ExecuteReader())
{
while (dbReader.Read())
@@ -330,36 +327,39 @@ namespace OpenSim.Data.MySQL
}
}
}
- catch (Exception e)
- {
- m_log.Error(
- string.Format(
- "[ASSETS DB]: MySql failure fetching asset set from {0}, count {1}. Exception ",
- start, count),
- e);
- }
+ return retList;
}
- dbcon.Close();
+ }
+ catch (Exception e)
+ {
+ m_log.Error($"[ASSETS DB]: MySql failure fetching asset set from {start}, count {1}. Exception ", e);
}
- return retList;
+ return [];
}
public override bool Delete(string id)
{
- using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
+ try
{
- dbcon.Open();
-
- using (MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon))
+ using (MySqlConnection dbcon = new(m_connectionString))
{
- cmd.Parameters.AddWithValue("?id", id);
- cmd.ExecuteNonQuery();
+ dbcon.Open();
+
+ using (MySqlCommand cmd = new("delete from assets where id=?id", dbcon))
+ {
+ cmd.Parameters.AddWithValue("?id", id);
+ cmd.ExecuteNonQuery();
+ }
}
- dbcon.Close();
+ return true;
+ }
+ catch (Exception e)
+ {
+ m_log.Error($"[ASSETS DB]: MySql failure on delete asset {id}", e);
}
- return true;
+ return false;
}
#endregion
diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
index 85a37adb0b..3539192126 100644
--- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
@@ -1007,7 +1007,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?UserId", props.UserId.ToString());
cmd.Parameters.AddWithValue("?TagId", props.TagId.ToString());
cmd.Parameters.AddWithValue("?DataKey", props.DataKey.ToString());
- cmd.Parameters.AddWithValue("?DataVal", props.DataKey.ToString());
+ cmd.Parameters.AddWithValue("?DataVal", props.DataVal.ToString());
cmd.ExecuteNonQuery();
}
diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs
index e3b2640ab6..6aeb331369 100644
--- a/OpenSim/Data/MySQL/MySQLXAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs
@@ -406,7 +406,7 @@ namespace OpenSim.Data.MySQL
HashSet exists = new HashSet();
string ids = "'" + string.Join("','", uuids) + "'";
- string sql = string.Format("SELECT ID FROM assets WHERE ID IN ({0})", ids);
+ string sql = $"SELECT ID FROM XAssetsMeta WHERE ID IN ({ids})";
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
diff --git a/OpenSim/Data/PGSQL/PGSQLManager.cs b/OpenSim/Data/PGSQL/PGSQLManager.cs
index 9864e27249..1a9685545d 100644
--- a/OpenSim/Data/PGSQL/PGSQLManager.cs
+++ b/OpenSim/Data/PGSQL/PGSQLManager.cs
@@ -224,7 +224,7 @@ namespace OpenSim.Data.PGSQL
}
if (PGFieldType == "boolean" || PGFieldType == "bit")
{
- return (value.ToString() == "true");
+ return "true".Equals(value.ToString(), StringComparison.OrdinalIgnoreCase);
}
if (PGFieldType == "timestamp with time zone")
{
@@ -307,7 +307,7 @@ namespace OpenSim.Data.PGSQL
internal NpgsqlParameter CreateParameter(string parameterName, object parameterObject, string PGFieldType)
{
//Tweak so we dont always have to add : sign
- if (parameterName.StartsWith(":")) parameterName = parameterName.Replace(":", "");
+ if (parameterName.StartsWith(':')) parameterName = parameterName[1..];
//HACK if object is null, it is turned into a string, there are no nullable type till now
if (parameterObject == null) parameterObject = "";
diff --git a/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs b/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs
index 099b21b7ea..a155eda269 100644
--- a/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs
@@ -1042,7 +1042,7 @@ namespace OpenSim.Data.PGSQL
cmd.Parameters.Add(m_database.CreateParameter("UserId", props.UserId.ToString()));
cmd.Parameters.Add(m_database.CreateParameter("TagId", props.TagId.ToString()));
cmd.Parameters.Add(m_database.CreateParameter("DataKey", props.DataKey.ToString()));
- cmd.Parameters.Add(m_database.CreateParameter("DataVal", props.DataKey.ToString()));
+ cmd.Parameters.Add(m_database.CreateParameter("DataVal", props.DataVal.ToString()));
cmd.ExecuteNonQuery();
}
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs
index a3a9d9cab2..8fdd111feb 100644
--- a/OpenSim/Services/AssetService/AssetService.cs
+++ b/OpenSim/Services/AssetService/AssetService.cs
@@ -156,8 +156,8 @@ namespace OpenSim.Services.AssetService
{
try
{
- UUID[] uuid = Array.ConvertAll(ids, id => UUID.Parse(id));
- return m_Database.AssetsExist(uuid);
+ UUID[] uuids = Array.ConvertAll(ids, id => UUID.Parse(id));
+ return m_Database.AssetsExist(uuids);
}
catch (Exception e)
{
@@ -192,13 +192,12 @@ namespace OpenSim.Services.AssetService
public virtual bool Delete(string id)
{
-// m_log.DebugFormat("[ASSET SERVICE]: Deleting asset {0}", id);
+ //m_log.DebugFormat("[ASSET SERVICE]: Deleting asset {0}", id);
- UUID assetID;
- if (!UUID.TryParse(id, out assetID))
- return false;
+ if (UUID.TryParse(id, out _))
+ return m_Database.Delete(id);
- return m_Database.Delete(id);
+ return false;
}
public void Get(string id, string ForeignAssetService, bool StoreOnLocalGrid, SimpleAssetRetrieved callBack)