aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/SQLite/SQLiteAssetData.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/SQLite/SQLiteAssetData.cs42
1 files changed, 27 insertions, 15 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs
index 7081f99..16e560c 100644
--- a/OpenSim/Data/SQLite/SQLiteAssetData.cs
+++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs
@@ -44,10 +44,10 @@ namespace OpenSim.Data.SQLite
44// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 private const string SelectAssetSQL = "select * from assets where UUID=:UUID"; 46 private const string SelectAssetSQL = "select * from assets where UUID=:UUID";
47 private const string SelectAssetMetadataSQL = "select Name, Description, Type, Temporary, asset_flags, UUID from assets limit :start, :count"; 47 private const string SelectAssetMetadataSQL = "select Name, Description, Type, Temporary, asset_flags, UUID, CreatorID from assets limit :start, :count";
48 private const string DeleteAssetSQL = "delete from assets where UUID=:UUID"; 48 private const string DeleteAssetSQL = "delete from assets where UUID=:UUID";
49 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)"; 49 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)";
50 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"; 50 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";
51 private const string assetSelect = "select * from assets"; 51 private const string assetSelect = "select * from assets";
52 52
53 private SqliteConnection m_conn; 53 private SqliteConnection m_conn;
@@ -137,6 +137,7 @@ namespace OpenSim.Data.SQLite
137 cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local)); 137 cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local));
138 cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary)); 138 cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary));
139 cmd.Parameters.Add(new SqliteParameter(":Flags", asset.Flags)); 139 cmd.Parameters.Add(new SqliteParameter(":Flags", asset.Flags));
140 cmd.Parameters.Add(new SqliteParameter(":CreatorID", asset.Metadata.CreatorID));
140 cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data)); 141 cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data));
141 142
142 cmd.ExecuteNonQuery(); 143 cmd.ExecuteNonQuery();
@@ -156,6 +157,7 @@ namespace OpenSim.Data.SQLite
156 cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local)); 157 cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local));
157 cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary)); 158 cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary));
158 cmd.Parameters.Add(new SqliteParameter(":Flags", asset.Flags)); 159 cmd.Parameters.Add(new SqliteParameter(":Flags", asset.Flags));
160 cmd.Parameters.Add(new SqliteParameter(":CreatorID", asset.Metadata.CreatorID));
159 cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data)); 161 cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data));
160 162
161 cmd.ExecuteNonQuery(); 163 cmd.ExecuteNonQuery();
@@ -223,7 +225,7 @@ namespace OpenSim.Data.SQLite
223 new UUID((String)row["UUID"]), 225 new UUID((String)row["UUID"]),
224 (String)row["Name"], 226 (String)row["Name"],
225 Convert.ToSByte(row["Type"]), 227 Convert.ToSByte(row["Type"]),
226 UUID.Zero.ToString() 228 (String)row["CreatorID"]
227 ); 229 );
228 230
229 asset.Description = (String) row["Description"]; 231 asset.Description = (String) row["Description"];
@@ -244,6 +246,7 @@ namespace OpenSim.Data.SQLite
244 metadata.Type = Convert.ToSByte(row["Type"]); 246 metadata.Type = Convert.ToSByte(row["Type"]);
245 metadata.Temporary = Convert.ToBoolean(row["Temporary"]); // Not sure if this is correct. 247 metadata.Temporary = Convert.ToBoolean(row["Temporary"]); // Not sure if this is correct.
246 metadata.Flags = (AssetFlags)Convert.ToInt32(row["asset_flags"]); 248 metadata.Flags = (AssetFlags)Convert.ToInt32(row["asset_flags"]);
249 metadata.CreatorID = row["CreatorID"].ToString();
247 250
248 // Current SHA1s are not stored/computed. 251 // Current SHA1s are not stored/computed.
249 metadata.SHA1 = new byte[] {}; 252 metadata.SHA1 = new byte[] {};
@@ -328,6 +331,25 @@ namespace OpenSim.Data.SQLite
328 get { return "SQLite Asset storage engine"; } 331 get { return "SQLite Asset storage engine"; }
329 } 332 }
330 333
334 // TODO: (AlexRa): one of these is to be removed eventually (?)
335
336 /// <summary>
337 /// Delete an asset from database
338 /// </summary>
339 /// <param name="uuid"></param>
340 public bool DeleteAsset(UUID uuid)
341 {
342 lock (this)
343 {
344 using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn))
345 {
346 cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString()));
347 cmd.ExecuteNonQuery();
348 }
349 }
350 return true;
351 }
352
331 public override bool Delete(string id) 353 public override bool Delete(string id)
332 { 354 {
333 UUID assetID; 355 UUID assetID;
@@ -335,17 +357,7 @@ namespace OpenSim.Data.SQLite
335 if (!UUID.TryParse(id, out assetID)) 357 if (!UUID.TryParse(id, out assetID))
336 return false; 358 return false;
337 359
338 lock (this) 360 return DeleteAsset(assetID);
339 {
340 using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn))
341 {
342 cmd.Parameters.Add(new SqliteParameter(":UUID", assetID.ToString()));
343
344 cmd.ExecuteNonQuery();
345 }
346 }
347
348 return true;
349 } 361 }
350 362
351 #endregion 363 #endregion