aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLAssetData.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs47
1 files changed, 27 insertions, 20 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index f16cd91..8569c90 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -75,6 +75,7 @@ namespace OpenSim.Data.MySQL
75 dbcon.Open(); 75 dbcon.Open();
76 Migration m = new Migration(dbcon, Assembly, "AssetStore"); 76 Migration m = new Migration(dbcon, Assembly, "AssetStore");
77 m.Update(); 77 m.Update();
78 dbcon.Close();
78 } 79 }
79 } 80 }
80 81
@@ -144,6 +145,7 @@ namespace OpenSim.Data.MySQL
144 string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e); 145 string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e);
145 } 146 }
146 } 147 }
148 dbcon.Close();
147 } 149 }
148 150
149 return asset; 151 return asset;
@@ -156,28 +158,27 @@ namespace OpenSim.Data.MySQL
156 /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> 158 /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks>
157 override public bool StoreAsset(AssetBase asset) 159 override public bool StoreAsset(AssetBase asset)
158 { 160 {
159 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 161 string assetName = asset.Name;
162 if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
160 { 163 {
161 dbcon.Open(); 164 assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
162 165 m_log.WarnFormat(
163 string assetName = asset.Name; 166 "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
164 if (asset.Name.Length > AssetBase.MAX_ASSET_NAME) 167 asset.Name, asset.ID, asset.Name.Length, assetName.Length);
165 { 168 }
166 assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
167 m_log.WarnFormat(
168 "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
169 asset.Name, asset.ID, asset.Name.Length, assetName.Length);
170 }
171 169
172 string assetDescription = asset.Description; 170 string assetDescription = asset.Description;
173 if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) 171 if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
174 { 172 {
175 assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); 173 assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
176 m_log.WarnFormat( 174 m_log.WarnFormat(
177 "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", 175 "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
178 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); 176 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
179 } 177 }
180 178
179 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
180 {
181 dbcon.Open();
181 using (MySqlCommand cmd = 182 using (MySqlCommand cmd =
182 new MySqlCommand( 183 new MySqlCommand(
183 "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" + 184 "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" +
@@ -200,15 +201,17 @@ namespace OpenSim.Data.MySQL
200 cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); 201 cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags);
201 cmd.Parameters.AddWithValue("?data", asset.Data); 202 cmd.Parameters.AddWithValue("?data", asset.Data);
202 cmd.ExecuteNonQuery(); 203 cmd.ExecuteNonQuery();
204 dbcon.Close();
203 return true; 205 return true;
204 } 206 }
205 catch (Exception e) 207 catch (Exception e)
206 { 208 {
207 m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}", 209 m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}",
208 asset.FullID, asset.Name, e.Message); 210 asset.FullID, asset.Name, e.Message);
211 dbcon.Close();
209 return false; 212 return false;
210 } 213 }
211 } 214 }
212 } 215 }
213 } 216 }
214 217
@@ -238,6 +241,7 @@ namespace OpenSim.Data.MySQL
238 e); 241 e);
239 } 242 }
240 } 243 }
244 dbcon.Close();
241 } 245 }
242 } 246 }
243 247
@@ -270,6 +274,7 @@ namespace OpenSim.Data.MySQL
270 } 274 }
271 } 275 }
272 } 276 }
277 dbcon.Close();
273 } 278 }
274 279
275 bool[] results = new bool[uuids.Length]; 280 bool[] results = new bool[uuids.Length];
@@ -334,6 +339,7 @@ namespace OpenSim.Data.MySQL
334 e); 339 e);
335 } 340 }
336 } 341 }
342 dbcon.Close();
337 } 343 }
338 344
339 return retList; 345 return retList;
@@ -350,6 +356,7 @@ namespace OpenSim.Data.MySQL
350 cmd.Parameters.AddWithValue("?id", id); 356 cmd.Parameters.AddWithValue("?id", id);
351 cmd.ExecuteNonQuery(); 357 cmd.ExecuteNonQuery();
352 } 358 }
359 dbcon.Close();
353 } 360 }
354 361
355 return true; 362 return true;