aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLXAssetData.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-03-15 23:42:16 +0000
committerJustin Clark-Casey (justincc)2013-03-15 23:42:16 +0000
commit35843e8ec8c58803664ab33ad52fd8e64a8765c6 (patch)
tree9e8d2d78dbe77fab19cde2333f101f98a2a9ff6d /OpenSim/Data/MySQL/MySQLXAssetData.cs
parentImplement access time updates on assets for XAssetService. (diff)
downloadopensim-SC_OLD-35843e8ec8c58803664ab33ad52fd8e64a8765c6.zip
opensim-SC_OLD-35843e8ec8c58803664ab33ad52fd8e64a8765c6.tar.gz
opensim-SC_OLD-35843e8ec8c58803664ab33ad52fd8e64a8765c6.tar.bz2
opensim-SC_OLD-35843e8ec8c58803664ab33ad52fd8e64a8765c6.tar.xz
Change the table and field names of XAssetService mysql db tables to be capitalized like Avatars, Friends, etc.
Also fixes access time being set on assets rather than XAssetsMeta This is to try and be somewhat consistent with other service tables that are mainly in this style. No migration is supplied, since nobody should be using this service yet except on a test basis.
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLXAssetData.cs92
1 files changed, 45 insertions, 47 deletions
diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs
index 273fbca..8c93825 100644
--- a/OpenSim/Data/MySQL/MySQLXAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs
@@ -138,10 +138,10 @@ namespace OpenSim.Data.MySQL
138 dbcon.Open(); 138 dbcon.Open();
139 139
140 using (MySqlCommand cmd = new MySqlCommand( 140 using (MySqlCommand cmd = new MySqlCommand(
141 "SELECT name, description, access_time, asset_type, local, temporary, asset_flags, creator_id, data FROM xassetsmeta JOIN xassetsdata ON xassetsmeta.hash = xassetsdata.hash WHERE id=?id", 141 "SELECT Name, Description, AccessTime, AssetType, Local, Temporary, AssetFlags, CreatorID, Data FROM XAssetsMeta JOIN XAssetsData ON XAssetsMeta.Hash = XAssetsData.Hash WHERE ID=?ID",
142 dbcon)) 142 dbcon))
143 { 143 {
144 cmd.Parameters.AddWithValue("?id", assetID.ToString()); 144 cmd.Parameters.AddWithValue("?ID", assetID.ToString());
145 145
146 try 146 try
147 { 147 {
@@ -149,18 +149,18 @@ namespace OpenSim.Data.MySQL
149 { 149 {
150 if (dbReader.Read()) 150 if (dbReader.Read())
151 { 151 {
152 asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["asset_type"], dbReader["creator_id"].ToString()); 152 asset = new AssetBase(assetID, (string)dbReader["Name"], (sbyte)dbReader["AssetType"], dbReader["CreatorID"].ToString());
153 asset.Data = (byte[])dbReader["data"]; 153 asset.Data = (byte[])dbReader["Data"];
154 asset.Description = (string)dbReader["description"]; 154 asset.Description = (string)dbReader["Description"];
155 155
156 string local = dbReader["local"].ToString(); 156 string local = dbReader["Local"].ToString();
157 if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) 157 if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase))
158 asset.Local = true; 158 asset.Local = true;
159 else 159 else
160 asset.Local = false; 160 asset.Local = false;
161 161
162 asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); 162 asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]);
163 asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); 163 asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
164 164
165 if (m_enableCompression) 165 if (m_enableCompression)
166 { 166 {
@@ -177,13 +177,13 @@ namespace OpenSim.Data.MySQL
177 } 177 }
178 } 178 }
179 179
180 UpdateAccessTime(asset.Metadata, (int)dbReader["access_time"]); 180 UpdateAccessTime(asset.Metadata, (int)dbReader["AccessTime"]);
181 } 181 }
182 } 182 }
183 } 183 }
184 catch (Exception e) 184 catch (Exception e)
185 { 185 {
186 m_log.Error("[MYSQL XASSET DATA]: Failure fetching asset " + assetID + ": " + e.Message); 186 m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e);
187 } 187 }
188 } 188 }
189 } 189 }
@@ -249,23 +249,23 @@ namespace OpenSim.Data.MySQL
249 { 249 {
250 using (MySqlCommand cmd = 250 using (MySqlCommand cmd =
251 new MySqlCommand( 251 new MySqlCommand(
252 "replace INTO xassetsmeta(id, hash, name, description, asset_type, local, temporary, create_time, access_time, asset_flags, creator_id)" + 252 "replace INTO XAssetsMeta(ID, Hash, Name, Description, AssetType, Local, Temporary, CreateTime, AccessTime, AssetFlags, CreatorID)" +
253 "VALUES(?id, ?hash, ?name, ?description, ?asset_type, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?creator_id)", 253 "VALUES(?ID, ?Hash, ?Name, ?Description, ?AssetType, ?Local, ?Temporary, ?CreateTime, ?AccessTime, ?AssetFlags, ?CreatorID)",
254 dbcon)) 254 dbcon))
255 { 255 {
256 // create unix epoch time 256 // create unix epoch time
257 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); 257 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
258 cmd.Parameters.AddWithValue("?id", asset.ID); 258 cmd.Parameters.AddWithValue("?ID", asset.ID);
259 cmd.Parameters.AddWithValue("?hash", hash); 259 cmd.Parameters.AddWithValue("?Hash", hash);
260 cmd.Parameters.AddWithValue("?name", assetName); 260 cmd.Parameters.AddWithValue("?Name", assetName);
261 cmd.Parameters.AddWithValue("?description", assetDescription); 261 cmd.Parameters.AddWithValue("?Description", assetDescription);
262 cmd.Parameters.AddWithValue("?asset_type", asset.Type); 262 cmd.Parameters.AddWithValue("?AssetType", asset.Type);
263 cmd.Parameters.AddWithValue("?local", asset.Local); 263 cmd.Parameters.AddWithValue("?Local", asset.Local);
264 cmd.Parameters.AddWithValue("?temporary", asset.Temporary); 264 cmd.Parameters.AddWithValue("?Temporary", asset.Temporary);
265 cmd.Parameters.AddWithValue("?create_time", now); 265 cmd.Parameters.AddWithValue("?CreateTime", now);
266 cmd.Parameters.AddWithValue("?access_time", now); 266 cmd.Parameters.AddWithValue("?AccessTime", now);
267 cmd.Parameters.AddWithValue("?creator_id", asset.Metadata.CreatorID); 267 cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID);
268 cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); 268 cmd.Parameters.AddWithValue("?AssetFlags", (int)asset.Flags);
269 cmd.ExecuteNonQuery(); 269 cmd.ExecuteNonQuery();
270 } 270 }
271 } 271 }
@@ -285,11 +285,11 @@ namespace OpenSim.Data.MySQL
285 { 285 {
286 using (MySqlCommand cmd = 286 using (MySqlCommand cmd =
287 new MySqlCommand( 287 new MySqlCommand(
288 "INSERT INTO xassetsdata(hash, data) VALUES(?hash, ?data)", 288 "INSERT INTO XAssetsData(Hash, Data) VALUES(?Hash, ?Data)",
289 dbcon)) 289 dbcon))
290 { 290 {
291 cmd.Parameters.AddWithValue("?hash", hash); 291 cmd.Parameters.AddWithValue("?Hash", hash);
292 cmd.Parameters.AddWithValue("?data", asset.Data); 292 cmd.Parameters.AddWithValue("?Data", asset.Data);
293 cmd.ExecuteNonQuery(); 293 cmd.ExecuteNonQuery();
294 } 294 }
295 } 295 }
@@ -332,15 +332,15 @@ namespace OpenSim.Data.MySQL
332 { 332 {
333 dbcon.Open(); 333 dbcon.Open();
334 MySqlCommand cmd = 334 MySqlCommand cmd =
335 new MySqlCommand("update assets set access_time=?access_time where id=?id", dbcon); 335 new MySqlCommand("update XAssetsMeta set AccessTime=?AccessTime where ID=?ID", dbcon);
336 336
337 try 337 try
338 { 338 {
339 using (cmd) 339 using (cmd)
340 { 340 {
341 // create unix epoch time 341 // create unix epoch time
342 cmd.Parameters.AddWithValue("?id", assetMetadata.ID); 342 cmd.Parameters.AddWithValue("?ID", assetMetadata.ID);
343 cmd.Parameters.AddWithValue("?access_time", (int)Utils.DateTimeToUnixTime(now)); 343 cmd.Parameters.AddWithValue("?AccessTime", (int)Utils.DateTimeToUnixTime(now));
344 cmd.ExecuteNonQuery(); 344 cmd.ExecuteNonQuery();
345 } 345 }
346 } 346 }
@@ -368,9 +368,9 @@ namespace OpenSim.Data.MySQL
368 368
369 bool exists = false; 369 bool exists = false;
370 370
371 using (MySqlCommand cmd = new MySqlCommand("SELECT hash FROM xassetsdata WHERE hash=?hash", dbcon)) 371 using (MySqlCommand cmd = new MySqlCommand("SELECT Hash FROM XAssetsData WHERE Hash=?Hash", dbcon))
372 { 372 {
373 cmd.Parameters.AddWithValue("?hash", hash); 373 cmd.Parameters.AddWithValue("?Hash", hash);
374 374
375 try 375 try
376 { 376 {
@@ -410,9 +410,9 @@ namespace OpenSim.Data.MySQL
410 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 410 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
411 { 411 {
412 dbcon.Open(); 412 dbcon.Open();
413 using (MySqlCommand cmd = new MySqlCommand("SELECT id FROM xassetsmeta WHERE id=?id", dbcon)) 413 using (MySqlCommand cmd = new MySqlCommand("SELECT ID FROM XAssetsMeta WHERE ID=?ID", dbcon))
414 { 414 {
415 cmd.Parameters.AddWithValue("?id", uuid.ToString()); 415 cmd.Parameters.AddWithValue("?ID", uuid.ToString());
416 416
417 try 417 try
418 { 418 {
@@ -427,8 +427,7 @@ namespace OpenSim.Data.MySQL
427 } 427 }
428 catch (Exception e) 428 catch (Exception e)
429 { 429 {
430 m_log.ErrorFormat( 430 m_log.Error(string.Format("[XASSETS DB]: MySql failure fetching asset {0}", uuid), e);
431 "[XASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString(), uuid);
432 } 431 }
433 } 432 }
434 } 433 }
@@ -438,7 +437,6 @@ namespace OpenSim.Data.MySQL
438 } 437 }
439 438
440 439
441
442 /// <summary> 440 /// <summary>
443 /// Returns a list of AssetMetadata objects. The list is a subset of 441 /// Returns a list of AssetMetadata objects. The list is a subset of
444 /// the entire data set offset by <paramref name="start" /> containing 442 /// the entire data set offset by <paramref name="start" /> containing
@@ -456,7 +454,7 @@ namespace OpenSim.Data.MySQL
456 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 454 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
457 { 455 {
458 dbcon.Open(); 456 dbcon.Open();
459 MySqlCommand cmd = new MySqlCommand("SELECT name,description,access_time,asset_type,temporary,id,asset_flags,creator_id FROM xassetsmeta LIMIT ?start, ?count", dbcon); 457 MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count", dbcon);
460 cmd.Parameters.AddWithValue("?start", start); 458 cmd.Parameters.AddWithValue("?start", start);
461 cmd.Parameters.AddWithValue("?count", count); 459 cmd.Parameters.AddWithValue("?count", count);
462 460
@@ -467,18 +465,18 @@ namespace OpenSim.Data.MySQL
467 while (dbReader.Read()) 465 while (dbReader.Read())
468 { 466 {
469 AssetMetadata metadata = new AssetMetadata(); 467 AssetMetadata metadata = new AssetMetadata();
470 metadata.Name = (string)dbReader["name"]; 468 metadata.Name = (string)dbReader["Name"];
471 metadata.Description = (string)dbReader["description"]; 469 metadata.Description = (string)dbReader["Description"];
472 metadata.Type = (sbyte)dbReader["asset_type"]; 470 metadata.Type = (sbyte)dbReader["AssetType"];
473 metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. 471 metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct.
474 metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); 472 metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
475 metadata.FullID = DBGuid.FromDB(dbReader["id"]); 473 metadata.FullID = DBGuid.FromDB(dbReader["ID"]);
476 metadata.CreatorID = dbReader["creator_id"].ToString(); 474 metadata.CreatorID = dbReader["CreatorID"].ToString();
477 475
478 // We'll ignore this for now - it appears unused! 476 // We'll ignore this for now - it appears unused!
479// metadata.SHA1 = dbReader["hash"]); 477// metadata.SHA1 = dbReader["hash"]);
480 478
481 UpdateAccessTime(metadata, (int)dbReader["access_time"]); 479 UpdateAccessTime(metadata, (int)dbReader["AccessTime"]);
482 480
483 retList.Add(metadata); 481 retList.Add(metadata);
484 } 482 }
@@ -504,9 +502,9 @@ namespace OpenSim.Data.MySQL
504 { 502 {
505 dbcon.Open(); 503 dbcon.Open();
506 504
507 using (MySqlCommand cmd = new MySqlCommand("delete from xassetsmeta where id=?id", dbcon)) 505 using (MySqlCommand cmd = new MySqlCommand("delete from XAssetsMeta where ID=?ID", dbcon))
508 { 506 {
509 cmd.Parameters.AddWithValue("?id", id); 507 cmd.Parameters.AddWithValue("?ID", id);
510 cmd.ExecuteNonQuery(); 508 cmd.ExecuteNonQuery();
511 } 509 }
512 510