aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/SQLite
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/SQLite
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/SQLite')
-rw-r--r--OpenSim/Data/SQLite/SQLiteAssetData.cs37
1 files changed, 22 insertions, 15 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs
index c32982e..1f32376 100644
--- a/OpenSim/Data/SQLite/SQLiteAssetData.cs
+++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs
@@ -152,7 +152,7 @@ namespace OpenSim.Data.SQLite
152 } 152 }
153 153
154 //m_log.Info("[ASSET DB]: Creating Asset " + asset.FullID.ToString()); 154 //m_log.Info("[ASSET DB]: Creating Asset " + asset.FullID.ToString());
155 if (ExistsAsset(asset.FullID)) 155 if (AssetsExist(new[] { asset.FullID })[0])
156 { 156 {
157 //LogAssetLoad(asset); 157 //LogAssetLoad(asset);
158 158
@@ -214,32 +214,39 @@ namespace OpenSim.Data.SQLite
214// } 214// }
215 215
216 /// <summary> 216 /// <summary>
217 /// Check if an asset exist in database 217 /// Check if the assets exist in the database.
218 /// </summary> 218 /// </summary>
219 /// <param name="uuid">The asset UUID</param> 219 /// <param name="uuids">The assets' IDs</param>
220 /// <returns>True if exist, or false.</returns> 220 /// <returns>For each asset: true if it exists, false otherwise</returns>
221 override public bool ExistsAsset(UUID uuid) 221 public override bool[] AssetsExist(UUID[] uuids)
222 { 222 {
223 lock (this) 223 if (uuids.Length == 0)
224 return new bool[0];
225
226 HashSet<UUID> exist = new HashSet<UUID>();
227
228 string ids = "'" + string.Join("','", uuids) + "'";
229 string sql = string.Format("SELECT id FROM assets WHERE id IN ({0})", ids);
230
231 lock (this)
224 { 232 {
225 using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn)) 233 using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn))
226 { 234 {
227 cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString()));
228 using (IDataReader reader = cmd.ExecuteReader()) 235 using (IDataReader reader = cmd.ExecuteReader())
229 { 236 {
230 if (reader.Read()) 237 while (reader.Read())
231 {
232 reader.Close();
233 return true;
234 }
235 else
236 { 238 {
237 reader.Close(); 239 UUID id = new UUID((string)reader["UUID"]);
238 return false; 240 exist.Add(id);
239 } 241 }
240 } 242 }
241 } 243 }
242 } 244 }
245
246 bool[] results = new bool[uuids.Length];
247 for (int i = 0; i < uuids.Length; i++)
248 results[i] = exist.Contains(uuids[i]);
249 return results;
243 } 250 }
244 251
245 /// <summary> 252 /// <summary>