aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/PGSQL/PGSQLXAssetData.cs
diff options
context:
space:
mode:
authorOren Hurvitz2014-03-31 11:53:12 +0300
committerOren Hurvitz2014-04-02 06:30:57 +0100
commitd1c3f8eef58b29eb8760eeb1ac03852a2387f927 (patch)
treeb8686f4ea01b6dac3740b9685734686e2178dd2d /OpenSim/Data/PGSQL/PGSQLXAssetData.cs
parentfix orphaned code in sun module per mantis 7068 (diff)
downloadopensim-SC_OLD-d1c3f8eef58b29eb8760eeb1ac03852a2387f927.zip
opensim-SC_OLD-d1c3f8eef58b29eb8760eeb1ac03852a2387f927.tar.gz
opensim-SC_OLD-d1c3f8eef58b29eb8760eeb1ac03852a2387f927.tar.bz2
opensim-SC_OLD-d1c3f8eef58b29eb8760eeb1ac03852a2387f927.tar.xz
Added assets service method AssetsExist(), which returns whether the given list of assets exist.
This method is used to optimize sending assets with embedded assets: e.g., when a Hypergrid visitor takes an item into the inventory.
Diffstat (limited to 'OpenSim/Data/PGSQL/PGSQLXAssetData.cs')
-rw-r--r--OpenSim/Data/PGSQL/PGSQLXAssetData.cs37
1 files changed, 37 insertions, 0 deletions
diff --git a/OpenSim/Data/PGSQL/PGSQLXAssetData.cs b/OpenSim/Data/PGSQL/PGSQLXAssetData.cs
index e959619..c6cebff 100644
--- a/OpenSim/Data/PGSQL/PGSQLXAssetData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLXAssetData.cs
@@ -407,6 +407,43 @@ namespace OpenSim.Data.PGSQL
407 } 407 }
408 408
409 /// <summary> 409 /// <summary>
410 /// Check if the assets exist in the database.
411 /// </summary>
412 /// <param name="uuids">The assets' IDs</param>
413 /// <returns>For each asset: true if it exists, false otherwise</returns>
414 public bool[] AssetsExist(UUID[] uuids)
415 {
416 if (uuids.Length == 0)
417 return new bool[0];
418
419 HashSet<UUID> exist = new HashSet<UUID>();
420
421 string ids = "'" + string.Join("','", uuids) + "'";
422 string sql = string.Format(@"SELECT ""ID"" FROM XAssetsMeta WHERE ""ID"" IN ({0})", ids);
423
424 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
425 {
426 conn.Open();
427 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
428 {
429 using (NpgsqlDataReader reader = cmd.ExecuteReader())
430 {
431 while (reader.Read())
432 {
433 UUID id = DBGuid.FromDB(reader["id"]);
434 exist.Add(id);
435 }
436 }
437 }
438 }
439
440 bool[] results = new bool[uuids.Length];
441 for (int i = 0; i < uuids.Length; i++)
442 results[i] = exist.Contains(uuids[i]);
443 return results;
444 }
445
446 /// <summary>
410 /// Check if the asset exists in the database 447 /// Check if the asset exists in the database
411 /// </summary> 448 /// </summary>
412 /// <param name="uuid">The asset UUID</param> 449 /// <param name="uuid">The asset UUID</param>