aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MSSQL
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/MSSQL
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/MSSQL')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLAssetData.cs35
1 files changed, 28 insertions, 7 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
index f3e008d..ce70396 100644
--- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
@@ -225,17 +225,38 @@ namespace OpenSim.Data.MSSQL
225// } 225// }
226 226
227 /// <summary> 227 /// <summary>
228 /// Check if asset exist in m_database 228 /// Check if the assets exist in the database.
229 /// </summary> 229 /// </summary>
230 /// <param name="uuid"></param> 230 /// <param name="uuids">The assets' IDs</param>
231 /// <returns>true if exist.</returns> 231 /// <returns>For each asset: true if it exists, false otherwise</returns>
232 override public bool ExistsAsset(UUID uuid) 232 public override bool[] AssetsExist(UUID[] uuids)
233 { 233 {
234 if (GetAsset(uuid) != null) 234 if (uuids.Length == 0)
235 return new bool[0];
236
237 HashSet<UUID> exist = new HashSet<UUID>();
238
239 string ids = "'" + string.Join("','", uuids) + "'";
240 string sql = string.Format("SELECT id FROM assets WHERE id IN ({0})", ids);
241
242 using (SqlConnection conn = new SqlConnection(m_connectionString))
243 using (SqlCommand cmd = new SqlCommand(sql, conn))
235 { 244 {
236 return true; 245 conn.Open();
246 using (SqlDataReader reader = cmd.ExecuteReader())
247 {
248 while (reader.Read())
249 {
250 UUID id = DBGuid.FromDB(reader["id"]);
251 exist.Add(id);
252 }
253 }
237 } 254 }
238 return false; 255
256 bool[] results = new bool[uuids.Length];
257 for (int i = 0; i < uuids.Length; i++)
258 results[i] = exist.Contains(uuids[i]);
259 return results;
239 } 260 }
240 261
241 /// <summary> 262 /// <summary>