diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteAssetData.cs | 42 |
1 files changed, 27 insertions, 15 deletions
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 | |||
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(); |
@@ -216,7 +218,7 @@ namespace OpenSim.Data.SQLite | |||
216 | new UUID((String)row["UUID"]), | 218 | new UUID((String)row["UUID"]), |
217 | (String)row["Name"], | 219 | (String)row["Name"], |
218 | Convert.ToSByte(row["Type"]), | 220 | Convert.ToSByte(row["Type"]), |
219 | UUID.Zero.ToString() | 221 | (String)row["CreatorID"] |
220 | ); | 222 | ); |
221 | 223 | ||
222 | asset.Description = (String) row["Description"]; | 224 | asset.Description = (String) row["Description"]; |
@@ -237,6 +239,7 @@ namespace OpenSim.Data.SQLite | |||
237 | metadata.Type = Convert.ToSByte(row["Type"]); | 239 | metadata.Type = Convert.ToSByte(row["Type"]); |
238 | metadata.Temporary = Convert.ToBoolean(row["Temporary"]); // Not sure if this is correct. | 240 | metadata.Temporary = Convert.ToBoolean(row["Temporary"]); // Not sure if this is correct. |
239 | metadata.Flags = (AssetFlags)Convert.ToInt32(row["asset_flags"]); | 241 | metadata.Flags = (AssetFlags)Convert.ToInt32(row["asset_flags"]); |
242 | metadata.CreatorID = row["CreatorID"].ToString(); | ||
240 | 243 | ||
241 | // Current SHA1s are not stored/computed. | 244 | // Current SHA1s are not stored/computed. |
242 | metadata.SHA1 = new byte[] {}; | 245 | metadata.SHA1 = new byte[] {}; |
@@ -321,6 +324,25 @@ namespace OpenSim.Data.SQLite | |||
321 | get { return "SQLite Asset storage engine"; } | 324 | get { return "SQLite Asset storage engine"; } |
322 | } | 325 | } |
323 | 326 | ||
327 | // TODO: (AlexRa): one of these is to be removed eventually (?) | ||
328 | |||
329 | /// <summary> | ||
330 | /// Delete an asset from database | ||
331 | /// </summary> | ||
332 | /// <param name="uuid"></param> | ||
333 | public bool DeleteAsset(UUID uuid) | ||
334 | { | ||
335 | lock (this) | ||
336 | { | ||
337 | using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn)) | ||
338 | { | ||
339 | cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString())); | ||
340 | cmd.ExecuteNonQuery(); | ||
341 | } | ||
342 | } | ||
343 | return true; | ||
344 | } | ||
345 | |||
324 | public override bool Delete(string id) | 346 | public override bool Delete(string id) |
325 | { | 347 | { |
326 | UUID assetID; | 348 | UUID assetID; |
@@ -328,17 +350,7 @@ namespace OpenSim.Data.SQLite | |||
328 | if (!UUID.TryParse(id, out assetID)) | 350 | if (!UUID.TryParse(id, out assetID)) |
329 | return false; | 351 | return false; |
330 | 352 | ||
331 | lock (this) | 353 | return DeleteAsset(assetID); |
332 | { | ||
333 | using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn)) | ||
334 | { | ||
335 | cmd.Parameters.Add(new SqliteParameter(":UUID", assetID.ToString())); | ||
336 | |||
337 | cmd.ExecuteNonQuery(); | ||
338 | } | ||
339 | } | ||
340 | |||
341 | return true; | ||
342 | } | 354 | } |
343 | 355 | ||
344 | #endregion | 356 | #endregion |