diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/PGSQL/PGSQLXAssetData.cs | 94 |
1 files changed, 49 insertions, 45 deletions
diff --git a/OpenSim/Data/PGSQL/PGSQLXAssetData.cs b/OpenSim/Data/PGSQL/PGSQLXAssetData.cs index 4f682f0..1798d20 100644 --- a/OpenSim/Data/PGSQL/PGSQLXAssetData.cs +++ b/OpenSim/Data/PGSQL/PGSQLXAssetData.cs | |||
@@ -141,7 +141,7 @@ namespace OpenSim.Data.PGSQL | |||
141 | 141 | ||
142 | using (NpgsqlCommand cmd = new NpgsqlCommand( | 142 | using (NpgsqlCommand cmd = new NpgsqlCommand( |
143 | @"SELECT name, description, access_time, ""AssetType"", local, temporary, asset_flags, creatorid, data | 143 | @"SELECT name, description, access_time, ""AssetType"", local, temporary, asset_flags, creatorid, data |
144 | FROM XAssetsMeta | 144 | FROM XAssetsMeta |
145 | JOIN XAssetsData ON XAssetsMeta.hash = XAssetsData.Hash WHERE id=:ID", | 145 | JOIN XAssetsData ON XAssetsMeta.hash = XAssetsData.Hash WHERE id=:ID", |
146 | dbcon)) | 146 | dbcon)) |
147 | { | 147 | { |
@@ -173,16 +173,18 @@ namespace OpenSim.Data.PGSQL | |||
173 | 173 | ||
174 | if (m_enableCompression) | 174 | if (m_enableCompression) |
175 | { | 175 | { |
176 | using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress)) | 176 | using(MemoryStream ms = new MemoryStream(asset.Data)) |
177 | using(GZipStream decompressionStream = new GZipStream(ms, CompressionMode.Decompress)) | ||
177 | { | 178 | { |
178 | MemoryStream outputStream = new MemoryStream(); | 179 | using(MemoryStream outputStream = new MemoryStream()) |
179 | WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue); | 180 | { |
180 | // int compressedLength = asset.Data.Length; | 181 | decompressionStream.CopyTo(outputStream,int.MaxValue); |
181 | asset.Data = outputStream.ToArray(); | 182 | // int compressedLength = asset.Data.Length; |
182 | 183 | asset.Data = outputStream.ToArray(); | |
183 | // m_log.DebugFormat( | 184 | } |
184 | // "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}", | 185 | // m_log.DebugFormat( |
185 | // asset.ID, asset.Name, asset.Data.Length, compressedLength); | 186 | // "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}", |
187 | // asset.ID, asset.Name, asset.Data.Length, compressedLength); | ||
186 | } | 188 | } |
187 | } | 189 | } |
188 | 190 | ||
@@ -223,16 +225,16 @@ namespace OpenSim.Data.PGSQL | |||
223 | { | 225 | { |
224 | assetName = asset.Name.Substring(0, 64); | 226 | assetName = asset.Name.Substring(0, 64); |
225 | m_log.WarnFormat( | 227 | m_log.WarnFormat( |
226 | "[XASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", | 228 | "[XASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", |
227 | asset.Name, asset.ID, asset.Name.Length, assetName.Length); | 229 | asset.Name, asset.ID, asset.Name.Length, assetName.Length); |
228 | } | 230 | } |
229 | 231 | ||
230 | string assetDescription = asset.Description; | 232 | string assetDescription = asset.Description; |
231 | if (asset.Description.Length > 64) | 233 | if (asset.Description.Length > 64) |
232 | { | 234 | { |
233 | assetDescription = asset.Description.Substring(0, 64); | 235 | assetDescription = asset.Description.Substring(0, 64); |
234 | m_log.WarnFormat( | 236 | m_log.WarnFormat( |
235 | "[XASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", | 237 | "[XASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", |
236 | asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); | 238 | asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); |
237 | } | 239 | } |
238 | 240 | ||
@@ -268,8 +270,8 @@ namespace OpenSim.Data.PGSQL | |||
268 | where not exists( Select id from XAssetsMeta where id = :ID); | 270 | where not exists( Select id from XAssetsMeta where id = :ID); |
269 | 271 | ||
270 | update XAssetsMeta | 272 | update XAssetsMeta |
271 | set id = :ID, hash = :Hash, name = :Name, description = :Description, | 273 | set id = :ID, hash = :Hash, name = :Name, description = :Description, |
272 | ""AssetType"" = :AssetType, local = :Local, temporary = :Temporary, create_time = :CreateTime, | 274 | ""AssetType"" = :AssetType, local = :Local, temporary = :Temporary, create_time = :CreateTime, |
273 | access_time = :AccessTime, asset_flags = :AssetFlags, creatorid = :CreatorID | 275 | access_time = :AccessTime, asset_flags = :AssetFlags, creatorid = :CreatorID |
274 | where id = :ID; | 276 | where id = :ID; |
275 | ", | 277 | ", |
@@ -321,13 +323,13 @@ namespace OpenSim.Data.PGSQL | |||
321 | { | 323 | { |
322 | m_log.ErrorFormat("[XASSET DB]: PGSQL failure creating asset data {0} with name \"{1}\". Error: {2}", | 324 | m_log.ErrorFormat("[XASSET DB]: PGSQL failure creating asset data {0} with name \"{1}\". Error: {2}", |
323 | asset.FullID, asset.Name, e.Message); | 325 | asset.FullID, asset.Name, e.Message); |
324 | 326 | ||
325 | transaction.Rollback(); | 327 | transaction.Rollback(); |
326 | 328 | ||
327 | return; | 329 | return; |
328 | } | 330 | } |
329 | } | 331 | } |
330 | 332 | ||
331 | transaction.Commit(); | 333 | transaction.Commit(); |
332 | } | 334 | } |
333 | } | 335 | } |
@@ -374,7 +376,7 @@ namespace OpenSim.Data.PGSQL | |||
374 | catch (Exception e) | 376 | catch (Exception e) |
375 | { | 377 | { |
376 | m_log.ErrorFormat( | 378 | m_log.ErrorFormat( |
377 | "[XASSET PGSQL DB]: Failure updating access_time for asset {0} with name {1} : {2}", | 379 | "[XASSET PGSQL DB]: Failure updating access_time for asset {0} with name {1} : {2}", |
378 | assetMetadata.ID, assetMetadata.Name, e.Message); | 380 | assetMetadata.ID, assetMetadata.Name, e.Message); |
379 | } | 381 | } |
380 | } | 382 | } |
@@ -518,40 +520,42 @@ namespace OpenSim.Data.PGSQL | |||
518 | using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString)) | 520 | using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString)) |
519 | { | 521 | { |
520 | dbcon.Open(); | 522 | dbcon.Open(); |
521 | NpgsqlCommand cmd = new NpgsqlCommand( @"SELECT name, description, access_time, ""AssetType"", temporary, id, asset_flags, creatorid | 523 | using(NpgsqlCommand cmd = new NpgsqlCommand(@"SELECT name, description, access_time, ""AssetType"", temporary, id, asset_flags, creatorid |
522 | FROM XAssetsMeta | 524 | FROM XAssetsMeta |
523 | LIMIT :start, :count", dbcon); | 525 | LIMIT :start, :count",dbcon)) |
524 | cmd.Parameters.Add(m_database.CreateParameter("start", start)); | ||
525 | cmd.Parameters.Add(m_database.CreateParameter("count", count)); | ||
526 | |||
527 | try | ||
528 | { | 526 | { |
529 | using (NpgsqlDataReader dbReader = cmd.ExecuteReader()) | 527 | cmd.Parameters.Add(m_database.CreateParameter("start",start)); |
528 | cmd.Parameters.Add(m_database.CreateParameter("count", count)); | ||
529 | |||
530 | try | ||
530 | { | 531 | { |
531 | while (dbReader.Read()) | 532 | using (NpgsqlDataReader dbReader = cmd.ExecuteReader()) |
532 | { | 533 | { |
533 | AssetMetadata metadata = new AssetMetadata(); | 534 | while (dbReader.Read()) |
534 | metadata.Name = (string)dbReader["name"]; | 535 | { |
535 | metadata.Description = (string)dbReader["description"]; | 536 | AssetMetadata metadata = new AssetMetadata(); |
536 | metadata.Type = Convert.ToSByte(dbReader["AssetType"]); | 537 | metadata.Name = (string)dbReader["name"]; |
537 | metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); | 538 | metadata.Description = (string)dbReader["description"]; |
538 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); | 539 | metadata.Type = Convert.ToSByte(dbReader["AssetType"]); |
539 | metadata.FullID = DBGuid.FromDB(dbReader["id"]); | 540 | metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); |
540 | metadata.CreatorID = dbReader["creatorid"].ToString(); | 541 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); |
542 | metadata.FullID = DBGuid.FromDB(dbReader["id"]); | ||
543 | metadata.CreatorID = dbReader["creatorid"].ToString(); | ||
541 | 544 | ||
542 | // We'll ignore this for now - it appears unused! | 545 | // We'll ignore this for now - it appears unused! |
543 | // metadata.SHA1 = dbReader["hash"]); | 546 | // metadata.SHA1 = dbReader["hash"]); |
544 | 547 | ||
545 | UpdateAccessTime(metadata, (int)dbReader["access_time"]); | 548 | UpdateAccessTime(metadata, (int)dbReader["access_time"]); |
546 | 549 | ||
547 | retList.Add(metadata); | 550 | retList.Add(metadata); |
551 | } | ||
548 | } | 552 | } |
549 | } | 553 | } |
550 | } | 554 | catch (Exception e) |
551 | catch (Exception e) | 555 | { |
552 | { | 556 | m_log.Error("[XASSETS DB]: PGSql failure fetching asset set" + Environment.NewLine + e.ToString()); |
553 | m_log.Error("[XASSETS DB]: PGSql failure fetching asset set" + Environment.NewLine + e.ToString()); | 557 | } |
554 | } | 558 | } |
555 | } | 559 | } |
556 | } | 560 | } |
557 | 561 | ||