diff options
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLAssetData.cs')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLAssetData.cs | 99 |
1 files changed, 52 insertions, 47 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 4d49733..6a4ccd7 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs | |||
@@ -139,42 +139,42 @@ namespace OpenSim.Data.MySQL | |||
139 | { | 139 | { |
140 | _dbConnection.CheckConnection(); | 140 | _dbConnection.CheckConnection(); |
141 | 141 | ||
142 | using (MySqlCommand cmd = new MySqlCommand( | 142 | MySqlCommand cmd = |
143 | "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", | 143 | new MySqlCommand( |
144 | _dbConnection.Connection)) | 144 | "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", |
145 | { | 145 | _dbConnection.Connection); |
146 | cmd.Parameters.AddWithValue("?id", assetID.ToString()); | 146 | cmd.Parameters.AddWithValue("?id", assetID.ToString()); |
147 | 147 | ||
148 | try | 148 | try |
149 | { | ||
150 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
149 | { | 151 | { |
150 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 152 | if (dbReader.Read()) |
151 | { | 153 | { |
152 | if (dbReader.Read()) | 154 | asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"]); |
153 | { | 155 | asset.Data = (byte[]) dbReader["data"]; |
154 | asset = new AssetBase(); | 156 | asset.Description = (string) dbReader["description"]; |
155 | asset.Data = (byte[])dbReader["data"]; | 157 | |
156 | asset.Description = (string)dbReader["description"]; | 158 | string local = dbReader["local"].ToString(); |
157 | asset.FullID = assetID; | 159 | if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) |
158 | 160 | asset.Local = true; | |
159 | string local = dbReader["local"].ToString(); | 161 | else |
160 | if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) | 162 | asset.Local = false; |
161 | asset.Local = true; | 163 | |
162 | else | 164 | asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); |
163 | asset.Local = false; | ||
164 | |||
165 | asset.Name = (string)dbReader["name"]; | ||
166 | asset.Type = (sbyte)dbReader["assetType"]; | ||
167 | asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); | ||
168 | } | ||
169 | } | 165 | } |
166 | dbReader.Close(); | ||
167 | cmd.Dispose(); | ||
170 | } | 168 | } |
171 | catch (Exception e) | 169 | if (asset != null) |
172 | { | 170 | UpdateAccessTime(asset); |
173 | m_log.ErrorFormat( | 171 | } |
174 | "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() | 172 | catch (Exception e) |
175 | + Environment.NewLine + "Reconnecting", assetID); | 173 | { |
176 | _dbConnection.Reconnect(); | 174 | m_log.ErrorFormat( |
177 | } | 175 | "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() |
176 | + Environment.NewLine + "Reconnecting", assetID); | ||
177 | _dbConnection.Reconnect(); | ||
178 | } | 178 | } |
179 | } | 179 | } |
180 | return asset; | 180 | return asset; |
@@ -291,27 +291,32 @@ namespace OpenSim.Data.MySQL | |||
291 | { | 291 | { |
292 | _dbConnection.CheckConnection(); | 292 | _dbConnection.CheckConnection(); |
293 | 293 | ||
294 | using (MySqlCommand cmd = new MySqlCommand( | 294 | MySqlCommand cmd = |
295 | "SELECT id FROM assets WHERE id=?id", | 295 | new MySqlCommand( |
296 | _dbConnection.Connection)) | 296 | "SELECT id FROM assets WHERE id=?id", |
297 | { | 297 | _dbConnection.Connection); |
298 | cmd.Parameters.AddWithValue("?id", uuid.ToString()); | ||
299 | 298 | ||
300 | try | 299 | cmd.Parameters.AddWithValue("?id", uuid.ToString()); |
300 | |||
301 | try | ||
302 | { | ||
303 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
301 | { | 304 | { |
302 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 305 | if (dbReader.Read()) |
303 | { | 306 | { |
304 | if (dbReader.Read()) | 307 | assetExists = true; |
305 | assetExists = true; | ||
306 | } | 308 | } |
309 | |||
310 | dbReader.Close(); | ||
311 | cmd.Dispose(); | ||
307 | } | 312 | } |
308 | catch (Exception e) | 313 | } |
309 | { | 314 | catch (Exception e) |
310 | m_log.ErrorFormat( | 315 | { |
311 | "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() | 316 | m_log.ErrorFormat( |
312 | + Environment.NewLine + "Attempting reconnection", uuid); | 317 | "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() |
313 | _dbConnection.Reconnect(); | 318 | + Environment.NewLine + "Attempting reconnection", uuid); |
314 | } | 319 | _dbConnection.Reconnect(); |
315 | } | 320 | } |
316 | } | 321 | } |
317 | 322 | ||