From 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb Mon Sep 17 00:00:00 2001
From: onefang
Date: Sun, 19 May 2019 21:24:15 +1000
Subject: Dump OpenSim 0.9.0.1 into it's own branch.
---
OpenSim/Data/MySQL/MySQLAssetData.cs | 112 +++++++++++++++++------------------
1 file changed, 56 insertions(+), 56 deletions(-)
(limited to 'OpenSim/Data/MySQL/MySQLAssetData.cs')
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index 5d8da17..8569c90 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -75,6 +75,7 @@ namespace OpenSim.Data.MySQL
dbcon.Open();
Migration m = new Migration(dbcon, Assembly, "AssetStore");
m.Update();
+ dbcon.Close();
}
}
@@ -144,6 +145,7 @@ namespace OpenSim.Data.MySQL
string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e);
}
}
+ dbcon.Close();
}
return asset;
@@ -154,65 +156,62 @@ namespace OpenSim.Data.MySQL
///
/// Asset UUID to create
/// On failure : Throw an exception and attempt to reconnect to database
- override public void StoreAsset(AssetBase asset)
+ override public bool StoreAsset(AssetBase asset)
{
+ string assetName = asset.Name;
+ if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
+ {
+ assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
+ m_log.WarnFormat(
+ "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
+ asset.Name, asset.ID, asset.Name.Length, assetName.Length);
+ }
+
+ string assetDescription = asset.Description;
+ if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
+ {
+ assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
+ m_log.WarnFormat(
+ "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
+ asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
+ }
+
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
dbcon.Open();
-
using (MySqlCommand cmd =
new MySqlCommand(
"replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" +
"VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)",
dbcon))
{
- string assetName = asset.Name;
- if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
- {
- assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
- m_log.WarnFormat(
- "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
- asset.Name, asset.ID, asset.Name.Length, assetName.Length);
- }
-
- string assetDescription = asset.Description;
- if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
- {
- assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
- m_log.WarnFormat(
- "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
- asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
- }
-
try
{
- using (cmd)
- {
- // create unix epoch time
- int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
- cmd.Parameters.AddWithValue("?id", asset.ID);
- cmd.Parameters.AddWithValue("?name", assetName);
- cmd.Parameters.AddWithValue("?description", assetDescription);
- cmd.Parameters.AddWithValue("?assetType", asset.Type);
- cmd.Parameters.AddWithValue("?local", asset.Local);
- cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
- cmd.Parameters.AddWithValue("?create_time", now);
- cmd.Parameters.AddWithValue("?access_time", now);
- cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID);
- cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags);
- cmd.Parameters.AddWithValue("?data", asset.Data);
- cmd.ExecuteNonQuery();
- }
+ // create unix epoch time
+ int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
+ cmd.Parameters.AddWithValue("?id", asset.ID);
+ cmd.Parameters.AddWithValue("?name", assetName);
+ cmd.Parameters.AddWithValue("?description", assetDescription);
+ cmd.Parameters.AddWithValue("?assetType", asset.Type);
+ cmd.Parameters.AddWithValue("?local", asset.Local);
+ cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
+ cmd.Parameters.AddWithValue("?create_time", now);
+ cmd.Parameters.AddWithValue("?access_time", now);
+ cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID);
+ cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags);
+ cmd.Parameters.AddWithValue("?data", asset.Data);
+ cmd.ExecuteNonQuery();
+ dbcon.Close();
+ return true;
}
catch (Exception e)
{
- m_log.Error(
- string.Format(
- "[ASSET DB]: MySQL failure creating asset {0} with name {1}. Exception ",
- asset.FullID, asset.Name)
- , e);
+ m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}",
+ asset.FullID, asset.Name, e.Message);
+ dbcon.Close();
+ return false;
}
- }
+ }
}
}
@@ -227,24 +226,22 @@ namespace OpenSim.Data.MySQL
{
try
{
- using (cmd)
- {
- // create unix epoch time
- int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
- cmd.Parameters.AddWithValue("?id", asset.ID);
- cmd.Parameters.AddWithValue("?access_time", now);
- cmd.ExecuteNonQuery();
- }
+ // create unix epoch time
+ int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
+ cmd.Parameters.AddWithValue("?id", asset.ID);
+ cmd.Parameters.AddWithValue("?access_time", now);
+ cmd.ExecuteNonQuery();
}
catch (Exception e)
{
m_log.Error(
string.Format(
- "[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ",
- asset.FullID, asset.Name),
+ "[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ",
+ asset.FullID, asset.Name),
e);
}
}
+ dbcon.Close();
}
}
@@ -277,6 +274,7 @@ namespace OpenSim.Data.MySQL
}
}
}
+ dbcon.Close();
}
bool[] results = new bool[uuids.Length];
@@ -336,11 +334,12 @@ namespace OpenSim.Data.MySQL
{
m_log.Error(
string.Format(
- "[ASSETS DB]: MySql failure fetching asset set from {0}, count {1}. Exception ",
- start, count),
+ "[ASSETS DB]: MySql failure fetching asset set from {0}, count {1}. Exception ",
+ start, count),
e);
}
}
+ dbcon.Close();
}
return retList;
@@ -357,6 +356,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?id", id);
cmd.ExecuteNonQuery();
}
+ dbcon.Close();
}
return true;
@@ -364,4 +364,4 @@ namespace OpenSim.Data.MySQL
#endregion
}
-}
\ No newline at end of file
+}
--
cgit v1.1