aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLAssetData.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2009-11-03 19:11:09 +0000
committerJustin Clark-Casey (justincc)2009-11-03 19:11:09 +0000
commitaf0e5d097480de264e7501e7d5d35328be5640bb (patch)
tree4ca5cd796ed9618dc9134a6e5eee1f7e7912bee4 /OpenSim/Data/MySQL/MySQLAssetData.cs
parentminor: remove some mono compiler warnings (diff)
parentFixed a couple of NREs in corner cases. (diff)
downloadopensim-SC_OLD-af0e5d097480de264e7501e7d5d35328be5640bb.zip
opensim-SC_OLD-af0e5d097480de264e7501e7d5d35328be5640bb.tar.gz
opensim-SC_OLD-af0e5d097480de264e7501e7d5d35328be5640bb.tar.bz2
opensim-SC_OLD-af0e5d097480de264e7501e7d5d35328be5640bb.tar.xz
Merge branch 'master' of ssh://justincc@opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLAssetData.cs')
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs102
1 files changed, 55 insertions, 47 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index 4d49733..1fe6d29 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -139,42 +139,45 @@ 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();
153 { 155 asset.Data = (byte[]) dbReader["data"];
154 asset = new AssetBase(); 156 asset.Description = (string) dbReader["description"];
155 asset.Data = (byte[])dbReader["data"]; 157 asset.FullID = assetID;
156 asset.Description = (string)dbReader["description"]; 158
157 asset.FullID = assetID; 159 string local = dbReader["local"].ToString();
158 160 if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase))
159 string local = dbReader["local"].ToString(); 161 asset.Local = true;
160 if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) 162 else
161 asset.Local = true; 163 asset.Local = false;
162 else 164
163 asset.Local = false; 165 asset.Name = (string) dbReader["name"];
164 166 asset.Type = (sbyte) dbReader["assetType"];
165 asset.Name = (string)dbReader["name"]; 167 asset.Temporary = Convert.ToBoolean(dbReader["temporary"]);
166 asset.Type = (sbyte)dbReader["assetType"];
167 asset.Temporary = Convert.ToBoolean(dbReader["temporary"]);
168 }
169 } 168 }
169 dbReader.Close();
170 cmd.Dispose();
170 } 171 }
171 catch (Exception e) 172 if (asset != null)
172 { 173 UpdateAccessTime(asset);
173 m_log.ErrorFormat( 174 }
174 "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() 175 catch (Exception e)
175 + Environment.NewLine + "Reconnecting", assetID); 176 {
176 _dbConnection.Reconnect(); 177 m_log.ErrorFormat(
177 } 178 "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString()
179 + Environment.NewLine + "Reconnecting", assetID);
180 _dbConnection.Reconnect();
178 } 181 }
179 } 182 }
180 return asset; 183 return asset;
@@ -291,27 +294,32 @@ namespace OpenSim.Data.MySQL
291 { 294 {
292 _dbConnection.CheckConnection(); 295 _dbConnection.CheckConnection();
293 296
294 using (MySqlCommand cmd = new MySqlCommand( 297 MySqlCommand cmd =
295 "SELECT id FROM assets WHERE id=?id", 298 new MySqlCommand(
296 _dbConnection.Connection)) 299 "SELECT id FROM assets WHERE id=?id",
297 { 300 _dbConnection.Connection);
298 cmd.Parameters.AddWithValue("?id", uuid.ToString()); 301
302 cmd.Parameters.AddWithValue("?id", uuid.ToString());
299 303
300 try 304 try
305 {
306 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
301 { 307 {
302 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 308 if (dbReader.Read())
303 { 309 {
304 if (dbReader.Read()) 310 assetExists = true;
305 assetExists = true;
306 } 311 }
312
313 dbReader.Close();
314 cmd.Dispose();
307 } 315 }
308 catch (Exception e) 316 }
309 { 317 catch (Exception e)
310 m_log.ErrorFormat( 318 {
311 "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() 319 m_log.ErrorFormat(
312 + Environment.NewLine + "Attempting reconnection", uuid); 320 "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString()
313 _dbConnection.Reconnect(); 321 + Environment.NewLine + "Attempting reconnection", uuid);
314 } 322 _dbConnection.Reconnect();
315 } 323 }
316 } 324 }
317 325