diff options
author | onefang | 2019-09-11 16:36:50 +1000 |
---|---|---|
committer | onefang | 2019-09-11 16:36:50 +1000 |
commit | 50cd1ffd32f69228e566f2b0b89f86ea0d9fe489 (patch) | |
tree | 52f2ab0c04f1a5d7d6ac5dc872981b4b156447e7 /OpenSim/Data/MySQL/MySQLFSAssetData.cs | |
parent | Renamed branch to SledjChisl. (diff) | |
parent | Bump to release flavour, build 0. (diff) | |
download | opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.zip opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.gz opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.bz2 opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.xz |
Merge branch 'SledjChisl'
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLFSAssetData.cs | 397 |
1 files changed, 208 insertions, 189 deletions
diff --git a/OpenSim/Data/MySQL/MySQLFSAssetData.cs b/OpenSim/Data/MySQL/MySQLFSAssetData.cs index 19e23b5..6c48607 100644 --- a/OpenSim/Data/MySQL/MySQLFSAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLFSAssetData.cs | |||
@@ -41,10 +41,8 @@ namespace OpenSim.Data.MySQL | |||
41 | { | 41 | { |
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
43 | 43 | ||
44 | protected MySqlConnection m_Connection = null; | ||
45 | protected string m_ConnectionString; | 44 | protected string m_ConnectionString; |
46 | protected string m_Table; | 45 | protected string m_Table; |
47 | protected Object m_connLock = new Object(); | ||
48 | 46 | ||
49 | /// <summary> | 47 | /// <summary> |
50 | /// Number of days that must pass before we update the access time on an asset when it has been fetched | 48 | /// Number of days that must pass before we update the access time on an asset when it has been fetched |
@@ -56,7 +54,7 @@ namespace OpenSim.Data.MySQL | |||
56 | { | 54 | { |
57 | get { return GetType().Assembly; } | 55 | get { return GetType().Assembly; } |
58 | } | 56 | } |
59 | 57 | ||
60 | public MySQLFSAssetData() | 58 | public MySQLFSAssetData() |
61 | { | 59 | { |
62 | } | 60 | } |
@@ -75,10 +73,13 @@ namespace OpenSim.Data.MySQL | |||
75 | 73 | ||
76 | try | 74 | try |
77 | { | 75 | { |
78 | OpenDatabase(); | 76 | using (MySqlConnection conn = new MySqlConnection(m_ConnectionString)) |
79 | 77 | { | |
80 | Migration m = new Migration(m_Connection, Assembly, "FSAssetStore"); | 78 | conn.Open(); |
81 | m.Update(); | 79 | Migration m = new Migration(conn, Assembly, "FSAssetStore"); |
80 | m.Update(); | ||
81 | conn.Close(); | ||
82 | } | ||
82 | } | 83 | } |
83 | catch (MySqlException e) | 84 | catch (MySqlException e) |
84 | { | 85 | { |
@@ -100,70 +101,37 @@ namespace OpenSim.Data.MySQL | |||
100 | 101 | ||
101 | #endregion | 102 | #endregion |
102 | 103 | ||
103 | private bool OpenDatabase() | 104 | private bool ExecuteNonQuery(MySqlCommand cmd) |
104 | { | 105 | { |
105 | try | 106 | using (MySqlConnection conn = new MySqlConnection(m_ConnectionString)) |
106 | { | ||
107 | m_Connection = new MySqlConnection(m_ConnectionString); | ||
108 | |||
109 | m_Connection.Open(); | ||
110 | } | ||
111 | catch (MySqlException e) | ||
112 | { | 107 | { |
113 | m_log.ErrorFormat("[FSASSETS]: Can't connect to database: {0}", | 108 | try |
114 | e.Message.ToString()); | ||
115 | |||
116 | return false; | ||
117 | } | ||
118 | |||
119 | return true; | ||
120 | } | ||
121 | |||
122 | private IDataReader ExecuteReader(MySqlCommand c) | ||
123 | { | ||
124 | IDataReader r = null; | ||
125 | MySqlConnection connection = (MySqlConnection) ((ICloneable)m_Connection).Clone(); | ||
126 | connection.Open(); | ||
127 | c.Connection = connection; | ||
128 | |||
129 | r = c.ExecuteReader(); | ||
130 | |||
131 | return r; | ||
132 | } | ||
133 | |||
134 | private void ExecuteNonQuery(MySqlCommand c) | ||
135 | { | ||
136 | lock (m_connLock) | ||
137 | { | ||
138 | bool errorSeen = false; | ||
139 | |||
140 | while (true) | ||
141 | { | 109 | { |
142 | try | 110 | conn.Open(); |
143 | { | 111 | } |
144 | c.ExecuteNonQuery(); | 112 | catch (MySqlException e) |
145 | } | 113 | { |
146 | catch (MySqlException) | 114 | m_log.ErrorFormat("[FSASSETS]: Database open failed with {0}", e.ToString()); |
147 | { | 115 | return false; |
148 | System.Threading.Thread.Sleep(500); | 116 | } |
149 | |||
150 | m_Connection.Close(); | ||
151 | m_Connection = (MySqlConnection) ((ICloneable)m_Connection).Clone(); | ||
152 | m_Connection.Open(); | ||
153 | c.Connection = m_Connection; | ||
154 | |||
155 | if (!errorSeen) | ||
156 | { | ||
157 | errorSeen = true; | ||
158 | continue; | ||
159 | } | ||
160 | m_log.ErrorFormat("[FSASSETS] MySQL command: {0}", c.CommandText); | ||
161 | throw; | ||
162 | } | ||
163 | 117 | ||
164 | break; | 118 | cmd.Connection = conn; |
119 | try | ||
120 | { | ||
121 | cmd.ExecuteNonQuery(); | ||
122 | } | ||
123 | catch (MySqlException e) | ||
124 | { | ||
125 | cmd.Connection = null; | ||
126 | conn.Close(); | ||
127 | m_log.ErrorFormat("[FSASSETS]: Query {0} failed with {1}", cmd.CommandText, e.ToString()); | ||
128 | return false; | ||
165 | } | 129 | } |
130 | conn.Close(); | ||
131 | cmd.Connection = null; | ||
166 | } | 132 | } |
133 | |||
134 | return true; | ||
167 | } | 135 | } |
168 | 136 | ||
169 | #region IFSAssetDataPlugin Members | 137 | #region IFSAssetDataPlugin Members |
@@ -172,63 +140,79 @@ namespace OpenSim.Data.MySQL | |||
172 | { | 140 | { |
173 | hash = String.Empty; | 141 | hash = String.Empty; |
174 | 142 | ||
175 | MySqlCommand cmd = new MySqlCommand(); | ||
176 | |||
177 | cmd.CommandText = String.Format("select id, name, description, type, hash, create_time, access_time, asset_flags from {0} where id = ?id", m_Table); | ||
178 | cmd.Parameters.AddWithValue("?id", id); | ||
179 | |||
180 | IDataReader reader = ExecuteReader(cmd); | ||
181 | |||
182 | if (!reader.Read()) | ||
183 | { | ||
184 | reader.Close(); | ||
185 | FreeCommand(cmd); | ||
186 | return null; | ||
187 | } | ||
188 | |||
189 | AssetMetadata meta = new AssetMetadata(); | 143 | AssetMetadata meta = new AssetMetadata(); |
190 | 144 | ||
191 | hash = reader["hash"].ToString(); | 145 | using (MySqlConnection conn = new MySqlConnection(m_ConnectionString)) |
146 | { | ||
147 | try | ||
148 | { | ||
149 | conn.Open(); | ||
150 | } | ||
151 | catch (MySqlException e) | ||
152 | { | ||
153 | m_log.ErrorFormat("[FSASSETS]: Database open failed with {0}", e.ToString()); | ||
154 | return null; | ||
155 | } | ||
192 | 156 | ||
193 | meta.ID = id; | 157 | using (MySqlCommand cmd = conn.CreateCommand()) |
194 | meta.FullID = new UUID(id); | 158 | { |
159 | cmd.CommandText = String.Format("select id, name, description, type, hash, create_time, asset_flags, access_time from {0} where id = ?id", m_Table); | ||
160 | cmd.Parameters.AddWithValue("?id", id); | ||
195 | 161 | ||
196 | meta.Name = reader["name"].ToString(); | 162 | using (IDataReader reader = cmd.ExecuteReader()) |
197 | meta.Description = reader["description"].ToString(); | 163 | { |
198 | meta.Type = (sbyte)Convert.ToInt32(reader["type"]); | 164 | if (!reader.Read()) |
199 | meta.ContentType = SLUtil.SLAssetTypeToContentType(meta.Type); | 165 | return null; |
200 | meta.CreationDate = Util.ToDateTime(Convert.ToInt32(reader["create_time"])); | ||
201 | meta.Flags = (AssetFlags)Convert.ToInt32(reader["asset_flags"]); | ||
202 | 166 | ||
203 | int AccessTime = Convert.ToInt32(reader["access_time"]); | 167 | hash = reader["hash"].ToString(); |
204 | 168 | ||
205 | reader.Close(); | 169 | meta.ID = id; |
170 | meta.FullID = new UUID(id); | ||
206 | 171 | ||
207 | UpdateAccessTime(AccessTime, cmd); | 172 | meta.Name = reader["name"].ToString(); |
173 | meta.Description = reader["description"].ToString(); | ||
174 | meta.Type = (sbyte)Convert.ToInt32(reader["type"]); | ||
175 | meta.ContentType = SLUtil.SLAssetTypeToContentType(meta.Type); | ||
176 | meta.CreationDate = Util.ToDateTime(Convert.ToInt32(reader["create_time"])); | ||
177 | meta.Flags = (AssetFlags)Convert.ToInt32(reader["asset_flags"]); | ||
208 | 178 | ||
209 | FreeCommand(cmd); | 179 | int AccessTime = Convert.ToInt32(reader["access_time"]); |
180 | UpdateAccessTime(id, AccessTime); | ||
181 | } | ||
182 | } | ||
183 | conn.Close(); | ||
184 | } | ||
210 | 185 | ||
211 | return meta; | 186 | return meta; |
212 | } | 187 | } |
213 | 188 | ||
214 | private void UpdateAccessTime(int AccessTime, MySqlCommand cmd) | 189 | private void UpdateAccessTime(string AssetID, int AccessTime) |
215 | { | 190 | { |
216 | // Reduce DB work by only updating access time if asset hasn't recently been accessed | 191 | // Reduce DB work by only updating access time if asset hasn't recently been accessed |
217 | // 0 By Default, Config option is "DaysBetweenAccessTimeUpdates" | 192 | // 0 By Default, Config option is "DaysBetweenAccessTimeUpdates" |
218 | if (DaysBetweenAccessTimeUpdates > 0 && (DateTime.UtcNow - Utils.UnixTimeToDateTime(AccessTime)).TotalDays < DaysBetweenAccessTimeUpdates) | 193 | if (DaysBetweenAccessTimeUpdates > 0 && (DateTime.UtcNow - Utils.UnixTimeToDateTime(AccessTime)).TotalDays < DaysBetweenAccessTimeUpdates) |
219 | return; | 194 | return; |
220 | 195 | ||
221 | cmd.CommandText = String.Format("UPDATE {0} SET `access_time` = UNIX_TIMESTAMP() WHERE `id` = ?id", m_Table); | 196 | using (MySqlConnection conn = new MySqlConnection(m_ConnectionString)) |
222 | 197 | { | |
223 | cmd.ExecuteNonQuery(); | 198 | try |
224 | } | 199 | { |
200 | conn.Open(); | ||
201 | } | ||
202 | catch (MySqlException e) | ||
203 | { | ||
204 | m_log.ErrorFormat("[FSASSETS]: Database open failed with {0}", e.ToString()); | ||
205 | return; | ||
206 | } | ||
225 | 207 | ||
226 | protected void FreeCommand(MySqlCommand cmd) | 208 | using (MySqlCommand cmd = conn.CreateCommand()) |
227 | { | 209 | { |
228 | MySqlConnection c = cmd.Connection; | 210 | cmd.CommandText = String.Format("UPDATE {0} SET `access_time` = UNIX_TIMESTAMP() WHERE `id` = ?id", m_Table); |
229 | cmd.Dispose(); | 211 | cmd.Parameters.AddWithValue("?id", AssetID); |
230 | c.Close(); | 212 | cmd.ExecuteNonQuery(); |
231 | c.Dispose(); | 213 | } |
214 | conn.Close(); | ||
215 | } | ||
232 | } | 216 | } |
233 | 217 | ||
234 | public bool Store(AssetMetadata meta, string hash) | 218 | public bool Store(AssetMetadata meta, string hash) |
@@ -238,37 +222,41 @@ namespace OpenSim.Data.MySQL | |||
238 | string oldhash; | 222 | string oldhash; |
239 | AssetMetadata existingAsset = Get(meta.ID, out oldhash); | 223 | AssetMetadata existingAsset = Get(meta.ID, out oldhash); |
240 | 224 | ||
241 | MySqlCommand cmd = m_Connection.CreateCommand(); | 225 | using (MySqlCommand cmd = new MySqlCommand()) |
242 | |||
243 | cmd.Parameters.AddWithValue("?id", meta.ID); | ||
244 | cmd.Parameters.AddWithValue("?name", meta.Name); | ||
245 | cmd.Parameters.AddWithValue("?description", meta.Description); | ||
246 | cmd.Parameters.AddWithValue("?type", meta.Type.ToString()); | ||
247 | cmd.Parameters.AddWithValue("?hash", hash); | ||
248 | cmd.Parameters.AddWithValue("?asset_flags", meta.Flags); | ||
249 | |||
250 | if (existingAsset == null) | ||
251 | { | 226 | { |
252 | cmd.CommandText = String.Format("insert into {0} (id, name, description, type, hash, asset_flags, create_time, access_time) values ( ?id, ?name, ?description, ?type, ?hash, ?asset_flags, UNIX_TIMESTAMP(), UNIX_TIMESTAMP())", m_Table); | 227 | cmd.Parameters.AddWithValue("?id", meta.ID); |
228 | cmd.Parameters.AddWithValue("?name", meta.Name); | ||
229 | cmd.Parameters.AddWithValue("?description", meta.Description); | ||
230 | // cmd.Parameters.AddWithValue("?type", meta.Type.ToString()); | ||
231 | cmd.Parameters.AddWithValue("?type", meta.Type); | ||
232 | cmd.Parameters.AddWithValue("?hash", hash); | ||
233 | cmd.Parameters.AddWithValue("?asset_flags", meta.Flags); | ||
234 | |||
235 | if (existingAsset == null) | ||
236 | { | ||
237 | cmd.CommandText = String.Format("insert into {0} (id, name, description, type, hash, asset_flags, create_time, access_time) values ( ?id, ?name, ?description, ?type, ?hash, ?asset_flags, UNIX_TIMESTAMP(), UNIX_TIMESTAMP())", m_Table); | ||
253 | 238 | ||
254 | ExecuteNonQuery(cmd); | 239 | ExecuteNonQuery(cmd); |
255 | 240 | ||
256 | cmd.Dispose(); | 241 | return true; |
242 | } | ||
257 | 243 | ||
258 | return true; | 244 | //cmd.CommandText = String.Format("update {0} set hash = ?hash, access_time = UNIX_TIMESTAMP() where id = ?id", m_Table); |
259 | } | ||
260 | 245 | ||
261 | //cmd.CommandText = String.Format("update {0} set hash = ?hash, access_time = UNIX_TIMESTAMP() where id = ?id", m_Table); | 246 | //ExecuteNonQuery(cmd); |
262 | 247 | ||
263 | //ExecuteNonQuery(cmd); | 248 | } |
264 | 249 | ||
265 | cmd.Dispose(); | 250 | // return false; |
266 | return false; | 251 | // if the asset already exits |
252 | // assume it was already correctly stored | ||
253 | // or regions will keep retry. | ||
254 | return true; | ||
267 | } | 255 | } |
268 | catch(Exception e) | 256 | catch(Exception e) |
269 | { | 257 | { |
270 | m_log.Error("[FSAssets] Failed to store asset with ID " + meta.ID); | 258 | m_log.Error("[FSAssets] Failed to store asset with ID " + meta.ID); |
271 | m_log.Error(e.ToString()); | 259 | m_log.Error(e.ToString()); |
272 | return false; | 260 | return false; |
273 | } | 261 | } |
274 | } | 262 | } |
@@ -283,26 +271,43 @@ namespace OpenSim.Data.MySQL | |||
283 | if (uuids.Length == 0) | 271 | if (uuids.Length == 0) |
284 | return new bool[0]; | 272 | return new bool[0]; |
285 | 273 | ||
274 | bool[] results = new bool[uuids.Length]; | ||
275 | for (int i = 0; i < uuids.Length; i++) | ||
276 | results[i] = false; | ||
277 | |||
286 | HashSet<UUID> exists = new HashSet<UUID>(); | 278 | HashSet<UUID> exists = new HashSet<UUID>(); |
287 | 279 | ||
288 | string ids = "'" + string.Join("','", uuids) + "'"; | 280 | string ids = "'" + string.Join("','", uuids) + "'"; |
289 | string sql = string.Format("select id from {1} where id in ({0})", ids, m_Table); | 281 | string sql = string.Format("select id from {1} where id in ({0})", ids, m_Table); |
290 | 282 | ||
291 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 283 | using (MySqlConnection conn = new MySqlConnection(m_ConnectionString)) |
292 | { | 284 | { |
293 | cmd.CommandText = sql; | 285 | try |
286 | { | ||
287 | conn.Open(); | ||
288 | } | ||
289 | catch (MySqlException e) | ||
290 | { | ||
291 | m_log.ErrorFormat("[FSASSETS]: Failed to open database: {0}", e.ToString()); | ||
292 | return results; | ||
293 | } | ||
294 | 294 | ||
295 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) | 295 | using (MySqlCommand cmd = conn.CreateCommand()) |
296 | { | 296 | { |
297 | while (dbReader.Read()) | 297 | cmd.CommandText = sql; |
298 | |||
299 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) | ||
298 | { | 300 | { |
299 | UUID id = DBGuid.FromDB(dbReader["ID"]); | 301 | while (dbReader.Read()) |
300 | exists.Add(id); | 302 | { |
303 | UUID id = DBGuid.FromDB(dbReader["ID"]); | ||
304 | exists.Add(id); | ||
305 | } | ||
301 | } | 306 | } |
302 | } | 307 | } |
308 | conn.Close(); | ||
303 | } | 309 | } |
304 | 310 | ||
305 | bool[] results = new bool[uuids.Length]; | ||
306 | for (int i = 0; i < uuids.Length; i++) | 311 | for (int i = 0; i < uuids.Length; i++) |
307 | results[i] = exists.Contains(uuids[i]); | 312 | results[i] = exists.Contains(uuids[i]); |
308 | return results; | 313 | return results; |
@@ -310,27 +315,43 @@ namespace OpenSim.Data.MySQL | |||
310 | 315 | ||
311 | public int Count() | 316 | public int Count() |
312 | { | 317 | { |
313 | MySqlCommand cmd = m_Connection.CreateCommand(); | 318 | int count = 0; |
314 | 319 | ||
315 | cmd.CommandText = String.Format("select count(*) as count from {0}", m_Table); | 320 | using (MySqlConnection conn = new MySqlConnection(m_ConnectionString)) |
316 | 321 | { | |
317 | IDataReader reader = ExecuteReader(cmd); | 322 | try |
323 | { | ||
324 | conn.Open(); | ||
325 | } | ||
326 | catch (MySqlException e) | ||
327 | { | ||
328 | m_log.ErrorFormat("[FSASSETS]: Failed to open database: {0}", e.ToString()); | ||
329 | return 0; | ||
330 | } | ||
318 | 331 | ||
319 | reader.Read(); | 332 | using(MySqlCommand cmd = conn.CreateCommand()) |
333 | { | ||
334 | cmd.CommandText = String.Format("select count(*) as count from {0}",m_Table); | ||
320 | 335 | ||
321 | int count = Convert.ToInt32(reader["count"]); | 336 | using (IDataReader reader = cmd.ExecuteReader()) |
337 | { | ||
338 | reader.Read(); | ||
322 | 339 | ||
323 | reader.Close(); | 340 | count = Convert.ToInt32(reader["count"]); |
324 | FreeCommand(cmd); | 341 | } |
342 | } | ||
343 | conn.Close(); | ||
344 | } | ||
325 | 345 | ||
326 | return count; | 346 | return count; |
327 | } | 347 | } |
328 | 348 | ||
329 | public bool Delete(string id) | 349 | public bool Delete(string id) |
330 | { | 350 | { |
331 | using (MySqlCommand cmd = m_Connection.CreateCommand()) | 351 | using(MySqlCommand cmd = new MySqlCommand()) |
332 | { | 352 | { |
333 | cmd.CommandText = String.Format("delete from {0} where id = ?id", m_Table); | 353 | |
354 | cmd.CommandText = String.Format("delete from {0} where id = ?id",m_Table); | ||
334 | 355 | ||
335 | cmd.Parameters.AddWithValue("?id", id); | 356 | cmd.Parameters.AddWithValue("?id", id); |
336 | 357 | ||
@@ -342,70 +363,68 @@ namespace OpenSim.Data.MySQL | |||
342 | 363 | ||
343 | public void Import(string conn, string table, int start, int count, bool force, FSStoreDelegate store) | 364 | public void Import(string conn, string table, int start, int count, bool force, FSStoreDelegate store) |
344 | { | 365 | { |
345 | MySqlConnection importConn; | 366 | int imported = 0; |
346 | |||
347 | try | ||
348 | { | ||
349 | importConn = new MySqlConnection(conn); | ||
350 | 367 | ||
351 | importConn.Open(); | 368 | using (MySqlConnection importConn = new MySqlConnection(conn)) |
352 | } | ||
353 | catch (MySqlException e) | ||
354 | { | 369 | { |
355 | m_log.ErrorFormat("[FSASSETS]: Can't connect to database: {0}", | 370 | try |
356 | e.Message.ToString()); | 371 | { |
357 | 372 | importConn.Open(); | |
358 | return; | 373 | } |
359 | } | 374 | catch (MySqlException e) |
375 | { | ||
376 | m_log.ErrorFormat("[FSASSETS]: Can't connect to database: {0}", | ||
377 | e.Message.ToString()); | ||
360 | 378 | ||
361 | int imported = 0; | 379 | return; |
380 | } | ||
362 | 381 | ||
363 | MySqlCommand cmd = importConn.CreateCommand(); | 382 | using (MySqlCommand cmd = importConn.CreateCommand()) |
383 | { | ||
384 | string limit = String.Empty; | ||
385 | if (count != -1) | ||
386 | { | ||
387 | limit = String.Format(" limit {0},{1}", start, count); | ||
388 | } | ||
364 | 389 | ||
365 | string limit = String.Empty; | 390 | cmd.CommandText = String.Format("select * from {0}{1}", table, limit); |
366 | if (count != -1) | ||
367 | { | ||
368 | limit = String.Format(" limit {0},{1}", start, count); | ||
369 | } | ||
370 | |||
371 | cmd.CommandText = String.Format("select * from {0}{1}", table, limit); | ||
372 | 391 | ||
373 | MainConsole.Instance.Output("Querying database"); | 392 | MainConsole.Instance.Output("Querying database"); |
374 | IDataReader reader = cmd.ExecuteReader(); | 393 | using (IDataReader reader = cmd.ExecuteReader()) |
394 | { | ||
395 | MainConsole.Instance.Output("Reading data"); | ||
375 | 396 | ||
376 | MainConsole.Instance.Output("Reading data"); | 397 | while (reader.Read()) |
398 | { | ||
399 | if ((imported % 100) == 0) | ||
400 | { | ||
401 | MainConsole.Instance.Output(String.Format("{0} assets imported so far", imported)); | ||
402 | } | ||
377 | 403 | ||
378 | while (reader.Read()) | 404 | AssetBase asset = new AssetBase(); |
379 | { | 405 | AssetMetadata meta = new AssetMetadata(); |
380 | if ((imported % 100) == 0) | ||
381 | { | ||
382 | MainConsole.Instance.Output(String.Format("{0} assets imported so far", imported)); | ||
383 | } | ||
384 | |||
385 | AssetBase asset = new AssetBase(); | ||
386 | AssetMetadata meta = new AssetMetadata(); | ||
387 | 406 | ||
388 | meta.ID = reader["id"].ToString(); | 407 | meta.ID = reader["id"].ToString(); |
389 | meta.FullID = new UUID(meta.ID); | 408 | meta.FullID = new UUID(meta.ID); |
390 | 409 | ||
391 | meta.Name = reader["name"].ToString(); | 410 | meta.Name = reader["name"].ToString(); |
392 | meta.Description = reader["description"].ToString(); | 411 | meta.Description = reader["description"].ToString(); |
393 | meta.Type = (sbyte)Convert.ToInt32(reader["assetType"]); | 412 | meta.Type = (sbyte)Convert.ToInt32(reader["assetType"]); |
394 | meta.ContentType = SLUtil.SLAssetTypeToContentType(meta.Type); | 413 | meta.ContentType = SLUtil.SLAssetTypeToContentType(meta.Type); |
395 | meta.CreationDate = Util.ToDateTime(Convert.ToInt32(reader["create_time"])); | 414 | meta.CreationDate = Util.ToDateTime(Convert.ToInt32(reader["create_time"])); |
396 | 415 | ||
397 | asset.Metadata = meta; | 416 | asset.Metadata = meta; |
398 | asset.Data = (byte[])reader["data"]; | 417 | asset.Data = (byte[])reader["data"]; |
399 | 418 | ||
400 | store(asset, force); | 419 | store(asset, force); |
401 | 420 | ||
402 | imported++; | 421 | imported++; |
422 | } | ||
423 | } | ||
424 | } | ||
425 | importConn.Close(); | ||
403 | } | 426 | } |
404 | 427 | ||
405 | reader.Close(); | ||
406 | cmd.Dispose(); | ||
407 | importConn.Close(); | ||
408 | |||
409 | MainConsole.Instance.Output(String.Format("Import done, {0} assets imported", imported)); | 428 | MainConsole.Instance.Output(String.Format("Import done, {0} assets imported", imported)); |
410 | } | 429 | } |
411 | 430 | ||