aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLXAssetData.cs92
-rw-r--r--OpenSim/Data/MySQL/Resources/XAssetStore.migrations30
2 files changed, 60 insertions, 62 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
diff --git a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations
index d3cca5e..0c49d0d 100644
--- a/OpenSim/Data/MySQL/Resources/XAssetStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/XAssetStore.migrations
@@ -3,24 +3,24 @@
3 3
4BEGIN; 4BEGIN;
5 5
6CREATE TABLE `xassetsmeta` ( 6CREATE TABLE `XAssetsMeta` (
7 `id` char(36) NOT NULL, 7 `ID` char(36) NOT NULL,
8 `hash` binary(32) NOT NULL, 8 `Hash` binary(32) NOT NULL,
9 `name` varchar(64) NOT NULL, 9 `Name` varchar(64) NOT NULL,
10 `description` varchar(64) NOT NULL, 10 `Description` varchar(64) NOT NULL,
11 `asset_type` tinyint(4) NOT NULL, 11 `AssetType` tinyint(4) NOT NULL,
12 `local` tinyint(1) NOT NULL, 12 `Local` tinyint(1) NOT NULL,
13 `temporary` tinyint(1) NOT NULL, 13 `Temporary` tinyint(1) NOT NULL,
14 `create_time` int(11) NOT NULL, 14 `CreateTime` int(11) NOT NULL,
15 `access_time` int(11) NOT NULL, 15 `AccessTime` int(11) NOT NULL,
16 `asset_flags` int(11) NOT NULL, 16 `AssetFlags` int(11) NOT NULL,
17 `creator_id` varchar(128) NOT NULL, 17 `CreatorID` varchar(128) NOT NULL,
18 PRIMARY KEY (`id`) 18 PRIMARY KEY (`id`)
19) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1'; 19) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1';
20 20
21CREATE TABLE `xassetsdata` ( 21CREATE TABLE `XAssetsData` (
22 `hash` binary(32) NOT NULL, 22 `Hash` binary(32) NOT NULL,
23 `data` longblob NOT NULL, 23 `Data` longblob NOT NULL,
24 PRIMARY KEY (`hash`) 24 PRIMARY KEY (`hash`)
25) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1'; 25) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1';
26 26