aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLAssetData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLAssetData.cs')
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs42
1 files changed, 20 insertions, 22 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index 21362b9..c96139d 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -257,46 +257,44 @@ namespace OpenSim.Data.MySQL
257 } 257 }
258 258
259 /// <summary> 259 /// <summary>
260 /// Check if the asset exists in the database 260 /// Check if the assets exist in the database.
261 /// </summary> 261 /// </summary>
262 /// <param name="uuid">The asset UUID</param> 262 /// <param name="uuidss">The assets' IDs</param>
263 /// <returns>true if it exists, false otherwise.</returns> 263 /// <returns>For each asset: true if it exists, false otherwise</returns>
264 override public bool ExistsAsset(UUID uuid) 264 public override bool[] AssetsExist(UUID[] uuids)
265 { 265 {
266// m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid); 266 if (uuids.Length == 0)
267 return new bool[0];
267 268
268 bool assetExists = false; 269 HashSet<UUID> exist = new HashSet<UUID>();
270
271 string ids = "'" + string.Join("','", uuids) + "'";
272 string sql = string.Format("SELECT id FROM assets WHERE id IN ({0})", ids);
269 273
270 lock (m_dbLock) 274 lock (m_dbLock)
271 { 275 {
272 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 276 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
273 { 277 {
274 dbcon.Open(); 278 dbcon.Open();
275 using (MySqlCommand cmd = new MySqlCommand("SELECT id FROM assets WHERE id=?id", dbcon)) 279 using (MySqlCommand cmd = new MySqlCommand(sql, dbcon))
276 { 280 {
277 cmd.Parameters.AddWithValue("?id", uuid.ToString()); 281 using (MySqlDataReader dbReader = cmd.ExecuteReader())
278
279 try
280 { 282 {
281 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 283 while (dbReader.Read())
282 { 284 {
283 if (dbReader.Read()) 285 UUID id = DBGuid.FromDB(dbReader["id"]);
284 { 286 exist.Add(id);
285// m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid);
286 assetExists = true;
287 }
288 } 287 }
289 } 288 }
290 catch (Exception e)
291 {
292 m_log.Error(
293 string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", uuid), e);
294 }
295 } 289 }
296 } 290 }
297 } 291 }
298 292
299 return assetExists; 293 bool[] results = new bool[uuids.Length];
294 for (int i = 0; i < uuids.Length; i++)
295 results[i] = exist.Contains(uuids[i]);
296
297 return results;
300 } 298 }
301 299
302 /// <summary> 300 /// <summary>