diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLXAssetData.cs | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index 91389ce..1bf6a9a 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs | |||
@@ -397,45 +397,43 @@ namespace OpenSim.Data.MySQL | |||
397 | } | 397 | } |
398 | 398 | ||
399 | /// <summary> | 399 | /// <summary> |
400 | /// Check if the asset exists in the database | 400 | /// Check if the assets exist in the database. |
401 | /// </summary> | 401 | /// </summary> |
402 | /// <param name="uuid">The asset UUID</param> | 402 | /// <param name="uuids">The asset UUID's</param> |
403 | /// <returns>true if it exists, false otherwise.</returns> | 403 | /// <returns>For each asset: true if it exists, false otherwise</returns> |
404 | public bool ExistsAsset(UUID uuid) | 404 | public bool[] AssetsExist(UUID[] uuids) |
405 | { | 405 | { |
406 | // m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid); | 406 | if (uuids.Length == 0) |
407 | return new bool[0]; | ||
408 | |||
409 | HashSet<UUID> exists = new HashSet<UUID>(); | ||
407 | 410 | ||
408 | bool assetExists = false; | 411 | string ids = "'" + string.Join("','", uuids) + "'"; |
412 | string sql = string.Format("SELECT ID FROM assets WHERE ID IN ({0})", ids); | ||
409 | 413 | ||
410 | lock (m_dbLock) | 414 | lock (m_dbLock) |
411 | { | 415 | { |
412 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 416 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
413 | { | 417 | { |
414 | dbcon.Open(); | 418 | dbcon.Open(); |
415 | using (MySqlCommand cmd = new MySqlCommand("SELECT ID FROM XAssetsMeta WHERE ID=?ID", dbcon)) | 419 | using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) |
416 | { | 420 | { |
417 | cmd.Parameters.AddWithValue("?ID", uuid.ToString()); | 421 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) |
418 | |||
419 | try | ||
420 | { | 422 | { |
421 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 423 | while (dbReader.Read()) |
422 | { | 424 | { |
423 | if (dbReader.Read()) | 425 | UUID id = DBGuid.FromDB(dbReader["ID"]); |
424 | { | 426 | exists.Add(id); |
425 | // m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid); | ||
426 | assetExists = true; | ||
427 | } | ||
428 | } | 427 | } |
429 | } | 428 | } |
430 | catch (Exception e) | ||
431 | { | ||
432 | m_log.Error(string.Format("[XASSETS DB]: MySql failure fetching asset {0}", uuid), e); | ||
433 | } | ||
434 | } | 429 | } |
435 | } | 430 | } |
436 | } | 431 | } |
437 | 432 | ||
438 | return assetExists; | 433 | bool[] results = new bool[uuids.Length]; |
434 | for (int i = 0; i < uuids.Length; i++) | ||
435 | results[i] = exists.Contains(uuids[i]); | ||
436 | return results; | ||
439 | } | 437 | } |
440 | 438 | ||
441 | 439 | ||