Added CreatorID to SQLite asset data
parent
ccee95552f
commit
c6977cbd4d
|
@ -44,10 +44,10 @@ namespace OpenSim.Data.SQLite
|
||||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private const string SelectAssetSQL = "select * from assets where UUID=:UUID";
|
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 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 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, Data=:Data where UUID=:UUID";
|
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 const string assetSelect = "select * from assets";
|
||||||
|
|
||||||
private SqliteConnection m_conn;
|
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(":Local", asset.Local));
|
||||||
cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary));
|
cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary));
|
||||||
cmd.Parameters.Add(new SqliteParameter(":Flags", asset.Flags));
|
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.Parameters.Add(new SqliteParameter(":Data", asset.Data));
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
|
@ -156,6 +157,7 @@ namespace OpenSim.Data.SQLite
|
||||||
cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local));
|
cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local));
|
||||||
cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary));
|
cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary));
|
||||||
cmd.Parameters.Add(new SqliteParameter(":Flags", asset.Flags));
|
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.Parameters.Add(new SqliteParameter(":Data", asset.Data));
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
|
@ -216,7 +218,7 @@ namespace OpenSim.Data.SQLite
|
||||||
new UUID((String)row["UUID"]),
|
new UUID((String)row["UUID"]),
|
||||||
(String)row["Name"],
|
(String)row["Name"],
|
||||||
Convert.ToSByte(row["Type"]),
|
Convert.ToSByte(row["Type"]),
|
||||||
UUID.Zero.ToString()
|
(String)row["CreatorID"]
|
||||||
);
|
);
|
||||||
|
|
||||||
asset.Description = (String) row["Description"];
|
asset.Description = (String) row["Description"];
|
||||||
|
@ -237,6 +239,7 @@ namespace OpenSim.Data.SQLite
|
||||||
metadata.Type = Convert.ToSByte(row["Type"]);
|
metadata.Type = Convert.ToSByte(row["Type"]);
|
||||||
metadata.Temporary = Convert.ToBoolean(row["Temporary"]); // Not sure if this is correct.
|
metadata.Temporary = Convert.ToBoolean(row["Temporary"]); // Not sure if this is correct.
|
||||||
metadata.Flags = (AssetFlags)Convert.ToInt32(row["asset_flags"]);
|
metadata.Flags = (AssetFlags)Convert.ToInt32(row["asset_flags"]);
|
||||||
|
metadata.CreatorID = row["CreatorID"].ToString();
|
||||||
|
|
||||||
// Current SHA1s are not stored/computed.
|
// Current SHA1s are not stored/computed.
|
||||||
metadata.SHA1 = new byte[] {};
|
metadata.SHA1 = new byte[] {};
|
||||||
|
@ -321,6 +324,25 @@ namespace OpenSim.Data.SQLite
|
||||||
get { return "SQLite Asset storage engine"; }
|
get { return "SQLite Asset storage engine"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: (AlexRa): one of these is to be removed eventually (?)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delete an asset from database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uuid"></param>
|
||||||
|
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)
|
public override bool Delete(string id)
|
||||||
{
|
{
|
||||||
UUID assetID;
|
UUID assetID;
|
||||||
|
@ -328,17 +350,7 @@ namespace OpenSim.Data.SQLite
|
||||||
if (!UUID.TryParse(id, out assetID))
|
if (!UUID.TryParse(id, out assetID))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
lock (this)
|
return DeleteAsset(assetID);
|
||||||
{
|
|
||||||
using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn))
|
|
||||||
{
|
|
||||||
cmd.Parameters.Add(new SqliteParameter(":UUID", assetID.ToString()));
|
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
Loading…
Reference in New Issue