From c6977cbd4d00159c034f66bfae40ee4984dea3f2 Mon Sep 17 00:00:00 2001
From: AlexRa
Date: Thu, 29 Apr 2010 12:44:03 +0300
Subject: Added CreatorID to SQLite asset data
---
OpenSim/Data/SQLite/SQLiteAssetData.cs | 42 ++++++++++++++++++++++------------
1 file changed, 27 insertions(+), 15 deletions(-)
(limited to 'OpenSim/Data/SQLite')
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs
index 0fc1f25..40e51db 100644
--- a/OpenSim/Data/SQLite/SQLiteAssetData.cs
+++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs
@@ -44,10 +44,10 @@ namespace OpenSim.Data.SQLite
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private const string SelectAssetSQL = "select * from assets where UUID=:UUID";
- private const string SelectAssetMetadataSQL = "select Name, Description, Type, Temporary, asset_flags, UUID from assets limit :start, :count";
+ private const string SelectAssetMetadataSQL = "select Name, Description, Type, Temporary, asset_flags, UUID, CreatorID from assets limit :start, :count";
private const string DeleteAssetSQL = "delete from assets where UUID=:UUID";
- private const string InsertAssetSQL = "insert into assets(UUID, Name, Description, Type, Local, Temporary, asset_flags, Data) values(:UUID, :Name, :Description, :Type, :Local, :Temporary, :Flags, :Data)";
- private const string UpdateAssetSQL = "update assets set Name=:Name, Description=:Description, Type=:Type, Local=:Local, Temporary=:Temporary, asset_flags=:Flags, Data=:Data where UUID=:UUID";
+ private const string InsertAssetSQL = "insert into assets(UUID, Name, Description, Type, Local, Temporary, asset_flags, CreatorID, Data) values(:UUID, :Name, :Description, :Type, :Local, :Temporary, :Flags, :CreatorID, :Data)";
+ private const string UpdateAssetSQL = "update assets set Name=:Name, Description=:Description, Type=:Type, Local=:Local, Temporary=:Temporary, asset_flags=:Flags, CreatorID=:CreatorID, Data=:Data where UUID=:UUID";
private const string assetSelect = "select * from assets";
private SqliteConnection m_conn;
@@ -137,6 +137,7 @@ namespace OpenSim.Data.SQLite
cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local));
cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary));
cmd.Parameters.Add(new SqliteParameter(":Flags", asset.Flags));
+ cmd.Parameters.Add(new SqliteParameter(":CreatorID", asset.Metadata.CreatorID));
cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data));
cmd.ExecuteNonQuery();
@@ -156,6 +157,7 @@ namespace OpenSim.Data.SQLite
cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local));
cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary));
cmd.Parameters.Add(new SqliteParameter(":Flags", asset.Flags));
+ cmd.Parameters.Add(new SqliteParameter(":CreatorID", asset.Metadata.CreatorID));
cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data));
cmd.ExecuteNonQuery();
@@ -216,7 +218,7 @@ namespace OpenSim.Data.SQLite
new UUID((String)row["UUID"]),
(String)row["Name"],
Convert.ToSByte(row["Type"]),
- UUID.Zero.ToString()
+ (String)row["CreatorID"]
);
asset.Description = (String) row["Description"];
@@ -237,6 +239,7 @@ namespace OpenSim.Data.SQLite
metadata.Type = Convert.ToSByte(row["Type"]);
metadata.Temporary = Convert.ToBoolean(row["Temporary"]); // Not sure if this is correct.
metadata.Flags = (AssetFlags)Convert.ToInt32(row["asset_flags"]);
+ metadata.CreatorID = row["CreatorID"].ToString();
// Current SHA1s are not stored/computed.
metadata.SHA1 = new byte[] {};
@@ -321,6 +324,25 @@ namespace OpenSim.Data.SQLite
get { return "SQLite Asset storage engine"; }
}
+ // TODO: (AlexRa): one of these is to be removed eventually (?)
+
+ ///
+ /// Delete an asset from database
+ ///
+ ///
+ public bool DeleteAsset(UUID uuid)
+ {
+ lock (this)
+ {
+ using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn))
+ {
+ cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString()));
+ cmd.ExecuteNonQuery();
+ }
+ }
+ return true;
+ }
+
public override bool Delete(string id)
{
UUID assetID;
@@ -328,17 +350,7 @@ namespace OpenSim.Data.SQLite
if (!UUID.TryParse(id, out assetID))
return false;
- lock (this)
- {
- using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn))
- {
- cmd.Parameters.Add(new SqliteParameter(":UUID", assetID.ToString()));
-
- cmd.ExecuteNonQuery();
- }
- }
-
- return true;
+ return DeleteAsset(assetID);
}
#endregion
--
cgit v1.1