aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/PGSQL/PGSQLAssetData.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/PGSQLAssetData.cs
parentfix orphaned code in sun module per mantis 7068 (diff)
downloadopensim-SC-d1c3f8eef58b29eb8760eeb1ac03852a2387f927.zip
opensim-SC-d1c3f8eef58b29eb8760eeb1ac03852a2387f927.tar.gz
opensim-SC-d1c3f8eef58b29eb8760eeb1ac03852a2387f927.tar.bz2
opensim-SC-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 '')
-rw-r--r--OpenSim/Data/PGSQL/PGSQLAssetData.cs35
1 files changed, 28 insertions, 7 deletions
diff --git a/OpenSim/Data/PGSQL/PGSQLAssetData.cs b/OpenSim/Data/PGSQL/PGSQLAssetData.cs
index ab74856..ca18dc9 100644
--- a/OpenSim/Data/PGSQL/PGSQLAssetData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLAssetData.cs
@@ -231,17 +231,38 @@ namespace OpenSim.Data.PGSQL
231// } 231// }
232 232
233 /// <summary> 233 /// <summary>
234 /// Check if asset exist in m_database 234 /// Check if the assets exist in the database.
235 /// </summary> 235 /// </summary>
236 /// <param name="uuid"></param> 236 /// <param name="uuids">The assets' IDs</param>
237 /// <returns>true if exist.</returns> 237 /// <returns>For each asset: true if it exists, false otherwise</returns>
238 override public bool ExistsAsset(UUID uuid) 238 public override bool[] AssetsExist(UUID[] uuids)
239 { 239 {
240 if (GetAsset(uuid) != null) 240 if (uuids.Length == 0)
241 return new bool[0];
242
243 HashSet<UUID> exist = new HashSet<UUID>();
244
245 string ids = "'" + string.Join("','", uuids) + "'";
246 string sql = string.Format("SELECT id FROM assets WHERE id IN ({0})", ids);
247
248 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
249 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
241 { 250 {
242 return true; 251 conn.Open();
252 using (NpgsqlDataReader reader = cmd.ExecuteReader())
253 {
254 while (reader.Read())
255 {
256 UUID id = DBGuid.FromDB(reader["id"]);
257 exist.Add(id);
258 }
259 }
243 } 260 }
244 return false; 261
262 bool[] results = new bool[uuids.Length];
263 for (int i = 0; i < uuids.Length; i++)
264 results[i] = exist.Contains(uuids[i]);
265 return results;
245 } 266 }
246 267
247 /// <summary> 268 /// <summary>