aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLXAssetData.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLXAssetData.cs57
1 files changed, 37 insertions, 20 deletions
diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs
index 2c6acde..9f9c9cf 100644
--- a/OpenSim/Data/MySQL/MySQLXAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs
@@ -97,6 +97,7 @@ namespace OpenSim.Data.MySQL
97 dbcon.Open(); 97 dbcon.Open();
98 Migration m = new Migration(dbcon, Assembly, "XAssetStore"); 98 Migration m = new Migration(dbcon, Assembly, "XAssetStore");
99 m.Update(); 99 m.Update();
100 dbcon.Close();
100 } 101 }
101 } 102 }
102 103
@@ -130,6 +131,7 @@ namespace OpenSim.Data.MySQL
130// m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID); 131// m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID);
131 132
132 AssetBase asset = null; 133 AssetBase asset = null;
134 int accessTime = 0;
133 135
134 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 136 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
135 { 137 {
@@ -140,7 +142,6 @@ namespace OpenSim.Data.MySQL
140 dbcon)) 142 dbcon))
141 { 143 {
142 cmd.Parameters.AddWithValue("?ID", assetID.ToString()); 144 cmd.Parameters.AddWithValue("?ID", assetID.ToString());
143
144 try 145 try
145 { 146 {
146 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 147 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
@@ -159,23 +160,7 @@ namespace OpenSim.Data.MySQL
159 160
160 asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]); 161 asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]);
161 asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); 162 asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
162 163 accessTime = (int)dbReader["AccessTime"];
163 if (m_enableCompression)
164 {
165 using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress))
166 {
167 MemoryStream outputStream = new MemoryStream();
168 WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue);
169// int compressedLength = asset.Data.Length;
170 asset.Data = outputStream.ToArray();
171
172// m_log.DebugFormat(
173// "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}",
174// asset.ID, asset.Name, asset.Data.Length, compressedLength);
175 }
176 }
177
178 UpdateAccessTime(asset.Metadata, (int)dbReader["AccessTime"]);
179 } 164 }
180 } 165 }
181 } 166 }
@@ -184,9 +169,38 @@ namespace OpenSim.Data.MySQL
184 m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e); 169 m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e);
185 } 170 }
186 } 171 }
172 dbcon.Close();
187 } 173 }
188 174
189 return asset; 175 if(asset == null)
176 return asset;
177
178 if(accessTime > 0)
179 {
180 try
181 {
182 UpdateAccessTime(asset.Metadata, accessTime);
183 }
184 catch { }
185 }
186
187 if (m_enableCompression && asset.Data != null)
188 {
189 using(MemoryStream ms = new MemoryStream(asset.Data))
190 using(GZipStream decompressionStream = new GZipStream(ms, CompressionMode.Decompress))
191 {
192 using(MemoryStream outputStream = new MemoryStream())
193 {
194 decompressionStream.CopyTo(outputStream, int.MaxValue);
195// int compressedLength = asset.Data.Length;
196 asset.Data = outputStream.ToArray();
197 }
198// m_log.DebugFormat(
199// "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}",
200// asset.ID, asset.Name, asset.Data.Length, compressedLength);
201 }
202 }
203 return asset;
190 } 204 }
191 205
192 /// <summary> 206 /// <summary>
@@ -303,6 +317,7 @@ namespace OpenSim.Data.MySQL
303 317
304 transaction.Commit(); 318 transaction.Commit();
305 } 319 }
320 dbcon.Close();
306 } 321 }
307 } 322 }
308 323
@@ -344,6 +359,7 @@ namespace OpenSim.Data.MySQL
344 "[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}", 359 "[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}",
345 assetMetadata.ID, assetMetadata.Name); 360 assetMetadata.ID, assetMetadata.Name);
346 } 361 }
362 dbcon.Close();
347 } 363 }
348 } 364 }
349 365
@@ -474,6 +490,7 @@ namespace OpenSim.Data.MySQL
474 m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); 490 m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString());
475 } 491 }
476 } 492 }
493 dbcon.Close();
477 } 494 }
478 495
479 return retList; 496 return retList;
@@ -492,9 +509,9 @@ namespace OpenSim.Data.MySQL
492 cmd.Parameters.AddWithValue("?ID", id); 509 cmd.Parameters.AddWithValue("?ID", id);
493 cmd.ExecuteNonQuery(); 510 cmd.ExecuteNonQuery();
494 } 511 }
495
496 // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we 512 // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we
497 // keep a reference count (?) 513 // keep a reference count (?)
514 dbcon.Close();
498 } 515 }
499 516
500 return true; 517 return true;