aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLXAssetData.cs
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-11-03 21:44:39 +1000
committerDavid Walter Seikel2016-11-03 21:44:39 +1000
commit134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch)
tree216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Data/MySQL/MySQLXAssetData.cs
parentMore changing to production grid. Double oops. (diff)
downloadopensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLXAssetData.cs431
1 files changed, 217 insertions, 214 deletions
diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs
index e6ac22e..af7e876 100644
--- a/OpenSim/Data/MySQL/MySQLXAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs
@@ -50,9 +50,13 @@ namespace OpenSim.Data.MySQL
50 get { return GetType().Assembly; } 50 get { return GetType().Assembly; }
51 } 51 }
52 52
53 /// <summary>
54 /// Number of days that must pass before we update the access time on an asset when it has been fetched.
55 /// </summary>
56 private const int DaysBetweenAccessTimeUpdates = 30;
57
53 private bool m_enableCompression = false; 58 private bool m_enableCompression = false;
54 private string m_connectionString; 59 private string m_connectionString;
55 private object m_dbLock = new object();
56 60
57 /// <summary> 61 /// <summary>
58 /// We can reuse this for all hashing since all methods are single-threaded through m_dbBLock 62 /// We can reuse this for all hashing since all methods are single-threaded through m_dbBLock
@@ -126,58 +130,58 @@ namespace OpenSim.Data.MySQL
126// m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID); 130// m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID);
127 131
128 AssetBase asset = null; 132 AssetBase asset = null;
129 lock (m_dbLock) 133
134 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
130 { 135 {
131 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 136 dbcon.Open();
137
138 using (MySqlCommand cmd = new MySqlCommand(
139 "SELECT Name, Description, AccessTime, AssetType, Local, Temporary, AssetFlags, CreatorID, Data FROM XAssetsMeta JOIN XAssetsData ON XAssetsMeta.Hash = XAssetsData.Hash WHERE ID=?ID",
140 dbcon))
132 { 141 {
133 dbcon.Open(); 142 cmd.Parameters.AddWithValue("?ID", assetID.ToString());
134 143
135 using (MySqlCommand cmd = new MySqlCommand( 144 try
136 "SELECT name, description, asset_type, local, temporary, asset_flags, creator_id, data FROM xassetsmeta JOIN xassetsdata ON xassetsmeta.hash = xassetsdata.hash WHERE id=?id",
137 dbcon))
138 { 145 {
139 cmd.Parameters.AddWithValue("?id", assetID.ToString()); 146 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
140
141 try
142 { 147 {
143 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 148 if (dbReader.Read())
144 { 149 {
145 if (dbReader.Read()) 150 asset = new AssetBase(assetID, (string)dbReader["Name"], (sbyte)dbReader["AssetType"], dbReader["CreatorID"].ToString());
146 { 151 asset.Data = (byte[])dbReader["Data"];
147 asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["asset_type"], dbReader["creator_id"].ToString()); 152 asset.Description = (string)dbReader["Description"];
148 asset.Data = (byte[])dbReader["data"];
149 asset.Description = (string)dbReader["description"];
150 153
151 string local = dbReader["local"].ToString(); 154 string local = dbReader["Local"].ToString();
152 if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) 155 if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase))
153 asset.Local = true; 156 asset.Local = true;
154 else 157 else
155 asset.Local = false; 158 asset.Local = false;
156 159
157 asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); 160 asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]);
158 asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); 161 asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
159 162
160 if (m_enableCompression) 163 if (m_enableCompression)
164 {
165 using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress))
161 { 166 {
162 using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress)) 167 MemoryStream outputStream = new MemoryStream();
163 { 168 WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue);
164 MemoryStream outputStream = new MemoryStream(); 169// int compressedLength = asset.Data.Length;
165 WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue); 170 asset.Data = outputStream.ToArray();
166 // int compressedLength = asset.Data.Length; 171
167 asset.Data = outputStream.ToArray(); 172// m_log.DebugFormat(
168 173// "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}",
169 // m_log.DebugFormat( 174// asset.ID, asset.Name, asset.Data.Length, compressedLength);
170 // "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}",
171 // asset.ID, asset.Name, asset.Data.Length, compressedLength);
172 }
173 } 175 }
174 } 176 }
177
178 UpdateAccessTime(asset.Metadata, (int)dbReader["AccessTime"]);
175 } 179 }
176 } 180 }
177 catch (Exception e) 181 }
178 { 182 catch (Exception e)
179 m_log.Error("[MYSQL XASSET DATA]: MySql failure fetching asset " + assetID + ": " + e.Message); 183 {
180 } 184 m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e);
181 } 185 }
182 } 186 }
183 } 187 }
@@ -192,148 +196,156 @@ namespace OpenSim.Data.MySQL
192 /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> 196 /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks>
193 public void StoreAsset(AssetBase asset) 197 public void StoreAsset(AssetBase asset)
194 { 198 {
195 lock (m_dbLock) 199// m_log.DebugFormat("[XASSETS DB]: Storing asset {0} {1}", asset.Name, asset.ID);
200
201 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
196 { 202 {
197 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 203 dbcon.Open();
204
205 using (MySqlTransaction transaction = dbcon.BeginTransaction())
198 { 206 {
199 dbcon.Open(); 207 string assetName = asset.Name;
208 if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
209 {
210 assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
211 m_log.WarnFormat(
212 "[XASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
213 asset.Name, asset.ID, asset.Name.Length, assetName.Length);
214 }
200 215
201 using (MySqlTransaction transaction = dbcon.BeginTransaction()) 216 string assetDescription = asset.Description;
217 if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
202 { 218 {
203 string assetName = asset.Name; 219 assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
204 if (asset.Name.Length > 64) 220 m_log.WarnFormat(
205 { 221 "[XASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
206 assetName = asset.Name.Substring(0, 64); 222 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
207 m_log.Warn("[XASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add"); 223 }
208 }
209
210 string assetDescription = asset.Description;
211 if (asset.Description.Length > 64)
212 {
213 assetDescription = asset.Description.Substring(0, 64);
214 m_log.Warn("[XASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add");
215 }
216 224
217 if (m_enableCompression) 225 if (m_enableCompression)
218 { 226 {
219 MemoryStream outputStream = new MemoryStream(); 227 MemoryStream outputStream = new MemoryStream();
220 228
221 using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress, false)) 229 using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress, false))
222 { 230 {
223 // Console.WriteLine(WebUtil.CopyTo(new MemoryStream(asset.Data), compressionStream, int.MaxValue)); 231// Console.WriteLine(WebUtil.CopyTo(new MemoryStream(asset.Data), compressionStream, int.MaxValue));
224 // We have to close the compression stream in order to make sure it writes everything out to the underlying memory output stream. 232 // We have to close the compression stream in order to make sure it writes everything out to the underlying memory output stream.
225 compressionStream.Close(); 233 compressionStream.Close();
226 byte[] compressedData = outputStream.ToArray(); 234 byte[] compressedData = outputStream.ToArray();
227 asset.Data = compressedData; 235 asset.Data = compressedData;
228 }
229 } 236 }
237 }
230 238
231 byte[] hash = hasher.ComputeHash(asset.Data); 239 byte[] hash = hasher.ComputeHash(asset.Data);
232 240
233// m_log.DebugFormat( 241// m_log.DebugFormat(
234// "[XASSET DB]: Compressed data size for {0} {1}, hash {2} is {3}", 242// "[XASSET DB]: Compressed data size for {0} {1}, hash {2} is {3}",
235// asset.ID, asset.Name, hash, compressedData.Length); 243// asset.ID, asset.Name, hash, compressedData.Length);
236 244
245 try
246 {
247 using (MySqlCommand cmd =
248 new MySqlCommand(
249 "replace INTO XAssetsMeta(ID, Hash, Name, Description, AssetType, Local, Temporary, CreateTime, AccessTime, AssetFlags, CreatorID)" +
250 "VALUES(?ID, ?Hash, ?Name, ?Description, ?AssetType, ?Local, ?Temporary, ?CreateTime, ?AccessTime, ?AssetFlags, ?CreatorID)",
251 dbcon))
252 {
253 // create unix epoch time
254 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
255 cmd.Parameters.AddWithValue("?ID", asset.ID);
256 cmd.Parameters.AddWithValue("?Hash", hash);
257 cmd.Parameters.AddWithValue("?Name", assetName);
258 cmd.Parameters.AddWithValue("?Description", assetDescription);
259 cmd.Parameters.AddWithValue("?AssetType", asset.Type);
260 cmd.Parameters.AddWithValue("?Local", asset.Local);
261 cmd.Parameters.AddWithValue("?Temporary", asset.Temporary);
262 cmd.Parameters.AddWithValue("?CreateTime", now);
263 cmd.Parameters.AddWithValue("?AccessTime", now);
264 cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID);
265 cmd.Parameters.AddWithValue("?AssetFlags", (int)asset.Flags);
266 cmd.ExecuteNonQuery();
267 }
268 }
269 catch (Exception e)
270 {
271 m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset metadata {0} with name \"{1}\". Error: {2}",
272 asset.FullID, asset.Name, e.Message);
273
274 transaction.Rollback();
275
276 return;
277 }
278
279 if (!ExistsData(dbcon, transaction, hash))
280 {
237 try 281 try
238 { 282 {
239 using (MySqlCommand cmd = 283 using (MySqlCommand cmd =
240 new MySqlCommand( 284 new MySqlCommand(
241 "replace INTO xassetsmeta(id, hash, name, description, asset_type, local, temporary, create_time, access_time, asset_flags, creator_id)" + 285 "INSERT INTO XAssetsData(Hash, Data) VALUES(?Hash, ?Data)",
242 "VALUES(?id, ?hash, ?name, ?description, ?asset_type, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?creator_id)",
243 dbcon)) 286 dbcon))
244 { 287 {
245 // create unix epoch time 288 cmd.Parameters.AddWithValue("?Hash", hash);
246 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); 289 cmd.Parameters.AddWithValue("?Data", asset.Data);
247 cmd.Parameters.AddWithValue("?id", asset.ID);
248 cmd.Parameters.AddWithValue("?hash", hash);
249 cmd.Parameters.AddWithValue("?name", assetName);
250 cmd.Parameters.AddWithValue("?description", assetDescription);
251 cmd.Parameters.AddWithValue("?asset_type", asset.Type);
252 cmd.Parameters.AddWithValue("?local", asset.Local);
253 cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
254 cmd.Parameters.AddWithValue("?create_time", now);
255 cmd.Parameters.AddWithValue("?access_time", now);
256 cmd.Parameters.AddWithValue("?creator_id", asset.Metadata.CreatorID);
257 cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags);
258 cmd.ExecuteNonQuery(); 290 cmd.ExecuteNonQuery();
259 } 291 }
260 } 292 }
261 catch (Exception e) 293 catch (Exception e)
262 { 294 {
263 m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset metadata {0} with name \"{1}\". Error: {2}", 295 m_log.ErrorFormat("[XASSET DB]: MySQL failure creating asset data {0} with name \"{1}\". Error: {2}",
264 asset.FullID, asset.Name, e.Message); 296 asset.FullID, asset.Name, e.Message);
265 297
266 transaction.Rollback(); 298 transaction.Rollback();
267 299
268 return; 300 return;
269 } 301 }
270
271 if (!ExistsData(dbcon, transaction, hash))
272 {
273 try
274 {
275 using (MySqlCommand cmd =
276 new MySqlCommand(
277 "INSERT INTO xassetsdata(hash, data) VALUES(?hash, ?data)",
278 dbcon))
279 {
280 cmd.Parameters.AddWithValue("?hash", hash);
281 cmd.Parameters.AddWithValue("?data", asset.Data);
282 cmd.ExecuteNonQuery();
283 }
284 }
285 catch (Exception e)
286 {
287 m_log.ErrorFormat("[XASSET DB]: MySQL failure creating asset data {0} with name \"{1}\". Error: {2}",
288 asset.FullID, asset.Name, e.Message);
289
290 transaction.Rollback();
291
292 return;
293 }
294 }
295
296 transaction.Commit();
297 } 302 }
303
304 transaction.Commit();
298 } 305 }
299 } 306 }
300 } 307 }
301 308
302// private void UpdateAccessTime(AssetBase asset) 309 /// <summary>
303// { 310 /// Updates the access time of the asset if it was accessed above a given threshhold amount of time.
304// lock (m_dbLock) 311 /// </summary>
305// { 312 /// <remarks>
306// using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 313 /// This gives us some insight into assets which haven't ben accessed for a long period. This is only done
307// { 314 /// over the threshold time to avoid excessive database writes as assets are fetched.
308// dbcon.Open(); 315 /// </remarks>
309// MySqlCommand cmd = 316 /// <param name='asset'></param>
310// new MySqlCommand("update assets set access_time=?access_time where id=?id", 317 /// <param name='accessTime'></param>
311// dbcon); 318 private void UpdateAccessTime(AssetMetadata assetMetadata, int accessTime)
312// 319 {
313// // need to ensure we dispose 320 DateTime now = DateTime.UtcNow;
314// try 321
315// { 322 if ((now - Utils.UnixTimeToDateTime(accessTime)).TotalDays < DaysBetweenAccessTimeUpdates)
316// using (cmd) 323 return;
317// { 324
318// // create unix epoch time 325 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
319// int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); 326 {
320// cmd.Parameters.AddWithValue("?id", asset.ID); 327 dbcon.Open();
321// cmd.Parameters.AddWithValue("?access_time", now); 328 MySqlCommand cmd =
322// cmd.ExecuteNonQuery(); 329 new MySqlCommand("update XAssetsMeta set AccessTime=?AccessTime where ID=?ID", dbcon);
323// cmd.Dispose(); 330
324// } 331 try
325// } 332 {
326// catch (Exception e) 333 using (cmd)
327// { 334 {
328// m_log.ErrorFormat( 335 // create unix epoch time
329// "[ASSETS DB]: " + 336 cmd.Parameters.AddWithValue("?ID", assetMetadata.ID);
330// "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() 337 cmd.Parameters.AddWithValue("?AccessTime", (int)Utils.DateTimeToUnixTime(now));
331// + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); 338 cmd.ExecuteNonQuery();
332// } 339 }
333// } 340 }
334// } 341 catch (Exception)
335// 342 {
336// } 343 m_log.ErrorFormat(
344 "[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}",
345 assetMetadata.ID, assetMetadata.Name);
346 }
347 }
348 }
337 349
338 /// <summary> 350 /// <summary>
339 /// We assume we already have the m_dbLock. 351 /// We assume we already have the m_dbLock.
@@ -349,9 +361,9 @@ namespace OpenSim.Data.MySQL
349 361
350 bool exists = false; 362 bool exists = false;
351 363
352 using (MySqlCommand cmd = new MySqlCommand("SELECT hash FROM xassetsdata WHERE hash=?hash", dbcon)) 364 using (MySqlCommand cmd = new MySqlCommand("SELECT Hash FROM XAssetsData WHERE Hash=?Hash", dbcon))
353 { 365 {
354 cmd.Parameters.AddWithValue("?hash", hash); 366 cmd.Parameters.AddWithValue("?Hash", hash);
355 367
356 try 368 try
357 { 369 {
@@ -376,48 +388,43 @@ namespace OpenSim.Data.MySQL
376 } 388 }
377 389
378 /// <summary> 390 /// <summary>
379 /// Check if the asset exists in the database 391 /// Check if the assets exist in the database.
380 /// </summary> 392 /// </summary>
381 /// <param name="uuid">The asset UUID</param> 393 /// <param name="uuids">The asset UUID's</param>
382 /// <returns>true if it exists, false otherwise.</returns> 394 /// <returns>For each asset: true if it exists, false otherwise</returns>
383 public bool ExistsAsset(UUID uuid) 395 public bool[] AssetsExist(UUID[] uuids)
384 { 396 {
385// m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid); 397 if (uuids.Length == 0)
398 return new bool[0];
399
400 HashSet<UUID> exists = new HashSet<UUID>();
386 401
387 bool assetExists = false; 402 string ids = "'" + string.Join("','", uuids) + "'";
403 string sql = string.Format("SELECT ID FROM assets WHERE ID IN ({0})", ids);
388 404
389 lock (m_dbLock) 405 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
390 { 406 {
391 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 407 dbcon.Open();
408 using (MySqlCommand cmd = new MySqlCommand(sql, dbcon))
392 { 409 {
393 dbcon.Open(); 410 using (MySqlDataReader dbReader = cmd.ExecuteReader())
394 using (MySqlCommand cmd = new MySqlCommand("SELECT id FROM xassetsmeta WHERE id=?id", dbcon))
395 { 411 {
396 cmd.Parameters.AddWithValue("?id", uuid.ToString()); 412 while (dbReader.Read())
397
398 try
399 {
400 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
401 {
402 if (dbReader.Read())
403 {
404// m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid);
405 assetExists = true;
406 }
407 }
408 }
409 catch (Exception e)
410 { 413 {
411 m_log.ErrorFormat( 414 UUID id = DBGuid.FromDB(dbReader["ID"]);
412 "[XASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString(), uuid); 415 exists.Add(id);
413 } 416 }
414 } 417 }
415 } 418 }
416 } 419 }
417 420
418 return assetExists; 421 bool[] results = new bool[uuids.Length];
422 for (int i = 0; i < uuids.Length; i++)
423 results[i] = exists.Contains(uuids[i]);
424 return results;
419 } 425 }
420 426
427
421 /// <summary> 428 /// <summary>
422 /// Returns a list of AssetMetadata objects. The list is a subset of 429 /// Returns a list of AssetMetadata objects. The list is a subset of
423 /// the entire data set offset by <paramref name="start" /> containing 430 /// the entire data set offset by <paramref name="start" /> containing
@@ -430,41 +437,40 @@ namespace OpenSim.Data.MySQL
430 { 437 {
431 List<AssetMetadata> retList = new List<AssetMetadata>(count); 438 List<AssetMetadata> retList = new List<AssetMetadata>(count);
432 439
433 lock (m_dbLock) 440 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
434 { 441 {
435 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 442 dbcon.Open();
436 { 443 MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count", dbcon);
437 dbcon.Open(); 444 cmd.Parameters.AddWithValue("?start", start);
438 MySqlCommand cmd = new MySqlCommand("SELECT name,description,asset_type,temporary,id,asset_flags,creator_id FROM xassetsmeta LIMIT ?start, ?count", dbcon); 445 cmd.Parameters.AddWithValue("?count", count);
439 cmd.Parameters.AddWithValue("?start", start);
440 cmd.Parameters.AddWithValue("?count", count);
441 446
442 try 447 try
448 {
449 using (MySqlDataReader dbReader = cmd.ExecuteReader())
443 { 450 {
444 using (MySqlDataReader dbReader = cmd.ExecuteReader()) 451 while (dbReader.Read())
445 { 452 {
446 while (dbReader.Read()) 453 AssetMetadata metadata = new AssetMetadata();
447 { 454 metadata.Name = (string)dbReader["Name"];
448 AssetMetadata metadata = new AssetMetadata(); 455 metadata.Description = (string)dbReader["Description"];
449 metadata.Name = (string)dbReader["name"]; 456 metadata.Type = (sbyte)dbReader["AssetType"];
450 metadata.Description = (string)dbReader["description"]; 457 metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct.
451 metadata.Type = (sbyte)dbReader["asset_type"]; 458 metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
452 metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. 459 metadata.FullID = DBGuid.FromDB(dbReader["ID"]);
453 metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); 460 metadata.CreatorID = dbReader["CreatorID"].ToString();
454 metadata.FullID = DBGuid.FromDB(dbReader["id"]); 461
455 metadata.CreatorID = dbReader["creator_id"].ToString(); 462 // We'll ignore this for now - it appears unused!
456
457 // We'll ignore this for now - it appears unused!
458// metadata.SHA1 = dbReader["hash"]); 463// metadata.SHA1 = dbReader["hash"]);
459 464
460 retList.Add(metadata); 465 UpdateAccessTime(metadata, (int)dbReader["AccessTime"]);
461 } 466
467 retList.Add(metadata);
462 } 468 }
463 } 469 }
464 catch (Exception e) 470 }
465 { 471 catch (Exception e)
466 m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); 472 {
467 } 473 m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString());
468 } 474 }
469 } 475 }
470 476
@@ -475,21 +481,18 @@ namespace OpenSim.Data.MySQL
475 { 481 {
476// m_log.DebugFormat("[XASSETS DB]: Deleting asset {0}", id); 482// m_log.DebugFormat("[XASSETS DB]: Deleting asset {0}", id);
477 483
478 lock (m_dbLock) 484 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
479 { 485 {
480 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 486 dbcon.Open();
481 {
482 dbcon.Open();
483
484 using (MySqlCommand cmd = new MySqlCommand("delete from xassetsmeta where id=?id", dbcon))
485 {
486 cmd.Parameters.AddWithValue("?id", id);
487 cmd.ExecuteNonQuery();
488 }
489 487
490 // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we 488 using (MySqlCommand cmd = new MySqlCommand("delete from XAssetsMeta where ID=?ID", dbcon))
491 // keep a reference count (?) 489 {
490 cmd.Parameters.AddWithValue("?ID", id);
491 cmd.ExecuteNonQuery();
492 } 492 }
493
494 // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we
495 // keep a reference count (?)
493 } 496 }
494 497
495 return true; 498 return true;