aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLAssetData.cs
diff options
context:
space:
mode:
authoronefang2019-05-19 21:24:15 +1000
committeronefang2019-05-19 21:24:15 +1000
commit5e4d6cab00cb29cd088ab7b62ab13aff103b64cb (patch)
treea9fbc62df9eb2d1d9ba2698d8552eae71eca20d8 /OpenSim/Data/MySQL/MySQLAssetData.cs
parentAdd a build script. (diff)
downloadopensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.zip
opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.gz
opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.bz2
opensim-SC_OLD-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.xz
Dump OpenSim 0.9.0.1 into it's own branch.
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLAssetData.cs')
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs112
1 files changed, 56 insertions, 56 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index 5d8da17..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;
@@ -154,65 +156,62 @@ namespace OpenSim.Data.MySQL
154 /// </summary> 156 /// </summary>
155 /// <param name="asset">Asset UUID to create</param> 157 /// <param name="asset">Asset UUID to create</param>
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 void StoreAsset(AssetBase asset) 159 override public bool StoreAsset(AssetBase asset)
158 { 160 {
161 string assetName = asset.Name;
162 if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
163 {
164 assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
165 m_log.WarnFormat(
166 "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
167 asset.Name, asset.ID, asset.Name.Length, assetName.Length);
168 }
169
170 string assetDescription = asset.Description;
171 if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
172 {
173 assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
174 m_log.WarnFormat(
175 "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
176 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
177 }
178
159 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 179 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
160 { 180 {
161 dbcon.Open(); 181 dbcon.Open();
162
163 using (MySqlCommand cmd = 182 using (MySqlCommand cmd =
164 new MySqlCommand( 183 new MySqlCommand(
165 "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)" +
166 "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)", 185 "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)",
167 dbcon)) 186 dbcon))
168 { 187 {
169 string assetName = asset.Name;
170 if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
171 {
172 assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
173 m_log.WarnFormat(
174 "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
175 asset.Name, asset.ID, asset.Name.Length, assetName.Length);
176 }
177
178 string assetDescription = asset.Description;
179 if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
180 {
181 assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
182 m_log.WarnFormat(
183 "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
184 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
185 }
186
187 try 188 try
188 { 189 {
189 using (cmd) 190 // create unix epoch time
190 { 191 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
191 // create unix epoch time 192 cmd.Parameters.AddWithValue("?id", asset.ID);
192 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); 193 cmd.Parameters.AddWithValue("?name", assetName);
193 cmd.Parameters.AddWithValue("?id", asset.ID); 194 cmd.Parameters.AddWithValue("?description", assetDescription);
194 cmd.Parameters.AddWithValue("?name", assetName); 195 cmd.Parameters.AddWithValue("?assetType", asset.Type);
195 cmd.Parameters.AddWithValue("?description", assetDescription); 196 cmd.Parameters.AddWithValue("?local", asset.Local);
196 cmd.Parameters.AddWithValue("?assetType", asset.Type); 197 cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
197 cmd.Parameters.AddWithValue("?local", asset.Local); 198 cmd.Parameters.AddWithValue("?create_time", now);
198 cmd.Parameters.AddWithValue("?temporary", asset.Temporary); 199 cmd.Parameters.AddWithValue("?access_time", now);
199 cmd.Parameters.AddWithValue("?create_time", now); 200 cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID);
200 cmd.Parameters.AddWithValue("?access_time", now); 201 cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags);
201 cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); 202 cmd.Parameters.AddWithValue("?data", asset.Data);
202 cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); 203 cmd.ExecuteNonQuery();
203 cmd.Parameters.AddWithValue("?data", asset.Data); 204 dbcon.Close();
204 cmd.ExecuteNonQuery(); 205 return true;
205 }
206 } 206 }
207 catch (Exception e) 207 catch (Exception e)
208 { 208 {
209 m_log.Error( 209 m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}",
210 string.Format( 210 asset.FullID, asset.Name, e.Message);
211 "[ASSET DB]: MySQL failure creating asset {0} with name {1}. Exception ", 211 dbcon.Close();
212 asset.FullID, asset.Name) 212 return false;
213 , e);
214 } 213 }
215 } 214 }
216 } 215 }
217 } 216 }
218 217
@@ -227,24 +226,22 @@ namespace OpenSim.Data.MySQL
227 { 226 {
228 try 227 try
229 { 228 {
230 using (cmd) 229 // create unix epoch time
231 { 230 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
232 // create unix epoch time 231 cmd.Parameters.AddWithValue("?id", asset.ID);
233 int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); 232 cmd.Parameters.AddWithValue("?access_time", now);
234 cmd.Parameters.AddWithValue("?id", asset.ID); 233 cmd.ExecuteNonQuery();
235 cmd.Parameters.AddWithValue("?access_time", now);
236 cmd.ExecuteNonQuery();
237 }
238 } 234 }
239 catch (Exception e) 235 catch (Exception e)
240 { 236 {
241 m_log.Error( 237 m_log.Error(
242 string.Format( 238 string.Format(
243 "[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ", 239 "[ASSETS DB]: Failure updating access_time for asset {0} with name {1}. Exception ",
244 asset.FullID, asset.Name), 240 asset.FullID, asset.Name),
245 e); 241 e);
246 } 242 }
247 } 243 }
244 dbcon.Close();
248 } 245 }
249 } 246 }
250 247
@@ -277,6 +274,7 @@ namespace OpenSim.Data.MySQL
277 } 274 }
278 } 275 }
279 } 276 }
277 dbcon.Close();
280 } 278 }
281 279
282 bool[] results = new bool[uuids.Length]; 280 bool[] results = new bool[uuids.Length];
@@ -336,11 +334,12 @@ namespace OpenSim.Data.MySQL
336 { 334 {
337 m_log.Error( 335 m_log.Error(
338 string.Format( 336 string.Format(
339 "[ASSETS DB]: MySql failure fetching asset set from {0}, count {1}. Exception ", 337 "[ASSETS DB]: MySql failure fetching asset set from {0}, count {1}. Exception ",
340 start, count), 338 start, count),
341 e); 339 e);
342 } 340 }
343 } 341 }
342 dbcon.Close();
344 } 343 }
345 344
346 return retList; 345 return retList;
@@ -357,6 +356,7 @@ namespace OpenSim.Data.MySQL
357 cmd.Parameters.AddWithValue("?id", id); 356 cmd.Parameters.AddWithValue("?id", id);
358 cmd.ExecuteNonQuery(); 357 cmd.ExecuteNonQuery();
359 } 358 }
359 dbcon.Close();
360 } 360 }
361 361
362 return true; 362 return true;
@@ -364,4 +364,4 @@ namespace OpenSim.Data.MySQL
364 364
365 #endregion 365 #endregion
366 } 366 }
367} \ No newline at end of file 367}