1
0

PGSQLXAssetData.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Data;
  30. using System.IO;
  31. using System.IO.Compression;
  32. using System.Reflection;
  33. using System.Security.Cryptography;
  34. using System.Text;
  35. using log4net;
  36. using OpenMetaverse;
  37. using OpenSim.Framework;
  38. using OpenSim.Data;
  39. using Npgsql;
  40. namespace OpenSim.Data.PGSQL
  41. {
  42. public class PGSQLXAssetData : IXAssetDataPlugin
  43. {
  44. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  45. protected virtual Assembly Assembly
  46. {
  47. get { return GetType().Assembly; }
  48. }
  49. /// <summary>
  50. /// Number of days that must pass before we update the access time on an asset when it has been fetched.
  51. /// </summary>
  52. private const int DaysBetweenAccessTimeUpdates = 30;
  53. private bool m_enableCompression = false;
  54. private PGSQLManager m_database;
  55. private string m_connectionString;
  56. private object m_dbLock = new object();
  57. /// <summary>
  58. /// We can reuse this for all hashing since all methods are single-threaded through m_dbBLock
  59. /// </summary>
  60. private HashAlgorithm hasher = SHA256.Create();
  61. #region IPlugin Members
  62. public string Version { get { return "1.0.0.0"; } }
  63. /// <summary>
  64. /// <para>Initialises Asset interface</para>
  65. /// <para>
  66. /// <list type="bullet">
  67. /// <item>Loads and initialises the PGSQL storage plugin.</item>
  68. /// <item>Warns and uses the obsolete pgsql_connection.ini if connect string is empty.</item>
  69. /// <item>Check for migration</item>
  70. /// </list>
  71. /// </para>
  72. /// </summary>
  73. /// <param name="connect">connect string</param>
  74. public void Initialise(string connect)
  75. {
  76. m_log.ErrorFormat("[PGSQL XASSETDATA]: ***********************************************************");
  77. m_log.ErrorFormat("[PGSQL XASSETDATA]: ***********************************************************");
  78. m_log.ErrorFormat("[PGSQL XASSETDATA]: ***********************************************************");
  79. m_log.ErrorFormat("[PGSQL XASSETDATA]: THIS PLUGIN IS STRICTLY EXPERIMENTAL.");
  80. m_log.ErrorFormat("[PGSQL XASSETDATA]: DO NOT USE FOR ANY DATA THAT YOU DO NOT MIND LOSING.");
  81. m_log.ErrorFormat("[PGSQL XASSETDATA]: DATABASE TABLES CAN CHANGE AT ANY TIME, CAUSING EXISTING DATA TO BE LOST.");
  82. m_log.ErrorFormat("[PGSQL XASSETDATA]: ***********************************************************");
  83. m_log.ErrorFormat("[PGSQL XASSETDATA]: ***********************************************************");
  84. m_log.ErrorFormat("[PGSQL XASSETDATA]: ***********************************************************");
  85. m_connectionString = connect;
  86. m_database = new PGSQLManager(m_connectionString);
  87. using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
  88. {
  89. dbcon.Open();
  90. Migration m = new Migration(dbcon, Assembly, "XAssetStore");
  91. m.Update();
  92. }
  93. }
  94. public void Initialise()
  95. {
  96. throw new NotImplementedException();
  97. }
  98. public void Dispose() { }
  99. /// <summary>
  100. /// The name of this DB provider
  101. /// </summary>
  102. public string Name
  103. {
  104. get { return "PGSQL XAsset storage engine"; }
  105. }
  106. #endregion
  107. #region IAssetDataPlugin Members
  108. /// <summary>
  109. /// Fetch Asset <paramref name="assetID"/> from database
  110. /// </summary>
  111. /// <param name="assetID">Asset UUID to fetch</param>
  112. /// <returns>Return the asset</returns>
  113. /// <remarks>On failure : throw an exception and attempt to reconnect to database</remarks>
  114. public AssetBase GetAsset(UUID assetID)
  115. {
  116. // m_log.DebugFormat("[PGSQL XASSET DATA]: Looking for asset {0}", assetID);
  117. AssetBase asset = null;
  118. lock (m_dbLock)
  119. {
  120. using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
  121. {
  122. dbcon.Open();
  123. using (NpgsqlCommand cmd = new NpgsqlCommand(
  124. @"SELECT name, description, access_time, ""AssetType"", local, temporary, asset_flags, creatorid, data
  125. FROM XAssetsMeta
  126. JOIN XAssetsData ON XAssetsMeta.hash = XAssetsData.Hash WHERE id=:ID",
  127. dbcon))
  128. {
  129. cmd.Parameters.Add(m_database.CreateParameter("ID", assetID));
  130. try
  131. {
  132. using (NpgsqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
  133. {
  134. if (dbReader.Read())
  135. {
  136. asset = new AssetBase(
  137. assetID,
  138. (string)dbReader["name"],
  139. Convert.ToSByte(dbReader["AssetType"]),
  140. dbReader["creatorid"].ToString());
  141. asset.Data = (byte[])dbReader["data"];
  142. asset.Description = (string)dbReader["description"];
  143. string local = dbReader["local"].ToString();
  144. if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase))
  145. asset.Local = true;
  146. else
  147. asset.Local = false;
  148. asset.Temporary = Convert.ToBoolean(dbReader["temporary"]);
  149. asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]);
  150. if (m_enableCompression)
  151. {
  152. using(MemoryStream ms = new MemoryStream(asset.Data))
  153. using(GZipStream decompressionStream = new GZipStream(ms, CompressionMode.Decompress))
  154. {
  155. using(MemoryStream outputStream = new MemoryStream())
  156. {
  157. decompressionStream.CopyTo(outputStream,int.MaxValue);
  158. // int compressedLength = asset.Data.Length;
  159. asset.Data = outputStream.ToArray();
  160. }
  161. // m_log.DebugFormat(
  162. // "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}",
  163. // asset.ID, asset.Name, asset.Data.Length, compressedLength);
  164. }
  165. }
  166. UpdateAccessTime(asset.Metadata, (int)dbReader["access_time"]);
  167. }
  168. }
  169. }
  170. catch (Exception e)
  171. {
  172. m_log.Error(string.Format("[PGSQL XASSET DATA]: Failure fetching asset {0}", assetID), e);
  173. }
  174. }
  175. }
  176. }
  177. return asset;
  178. }
  179. /// <summary>
  180. /// Create an asset in database, or update it if existing.
  181. /// </summary>
  182. /// <param name="asset">Asset UUID to create</param>
  183. /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks>
  184. public void StoreAsset(AssetBase asset)
  185. {
  186. // m_log.DebugFormat("[XASSETS DB]: Storing asset {0} {1}", asset.Name, asset.ID);
  187. lock (m_dbLock)
  188. {
  189. using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
  190. {
  191. dbcon.Open();
  192. using (NpgsqlTransaction transaction = dbcon.BeginTransaction())
  193. {
  194. string assetName = asset.Name;
  195. if (asset.Name.Length > 64)
  196. {
  197. assetName = asset.Name.Substring(0, 64);
  198. m_log.WarnFormat(
  199. "[XASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
  200. asset.Name, asset.ID, asset.Name.Length, assetName.Length);
  201. }
  202. string assetDescription = asset.Description;
  203. if (asset.Description.Length > 64)
  204. {
  205. assetDescription = asset.Description.Substring(0, 64);
  206. m_log.WarnFormat(
  207. "[XASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
  208. asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
  209. }
  210. if (m_enableCompression)
  211. {
  212. MemoryStream outputStream = new MemoryStream();
  213. using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress, false))
  214. {
  215. // Console.WriteLine(WebUtil.CopyTo(new MemoryStream(asset.Data), compressionStream, int.MaxValue));
  216. // We have to close the compression stream in order to make sure it writes everything out to the underlying memory output stream.
  217. compressionStream.Close();
  218. byte[] compressedData = outputStream.ToArray();
  219. asset.Data = compressedData;
  220. }
  221. }
  222. byte[] hash = hasher.ComputeHash(asset.Data);
  223. UUID asset_id;
  224. UUID.TryParse(asset.ID, out asset_id);
  225. // m_log.DebugFormat(
  226. // "[XASSET DB]: Compressed data size for {0} {1}, hash {2} is {3}",
  227. // asset.ID, asset.Name, hash, compressedData.Length);
  228. try
  229. {
  230. using (NpgsqlCommand cmd =
  231. new NpgsqlCommand(
  232. @"insert INTO XAssetsMeta(id, hash, name, description, ""AssetType"", local, temporary, create_time, access_time, asset_flags, creatorid)
  233. Select :ID, :Hash, :Name, :Description, :AssetType, :Local, :Temporary, :CreateTime, :AccessTime, :AssetFlags, :CreatorID
  234. where not exists( Select id from XAssetsMeta where id = :ID);
  235. update XAssetsMeta
  236. set id = :ID, hash = :Hash, name = :Name, description = :Description,
  237. ""AssetType"" = :AssetType, local = :Local, temporary = :Temporary, create_time = :CreateTime,
  238. access_time = :AccessTime, asset_flags = :AssetFlags, creatorid = :CreatorID
  239. where id = :ID;
  240. ",
  241. dbcon))
  242. {
  243. // create unix epoch time
  244. int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
  245. cmd.Parameters.Add(m_database.CreateParameter("ID", asset_id));
  246. cmd.Parameters.Add(m_database.CreateParameter("Hash", hash));
  247. cmd.Parameters.Add(m_database.CreateParameter("Name", assetName));
  248. cmd.Parameters.Add(m_database.CreateParameter("Description", assetDescription));
  249. cmd.Parameters.Add(m_database.CreateParameter("AssetType", asset.Type));
  250. cmd.Parameters.Add(m_database.CreateParameter("Local", asset.Local));
  251. cmd.Parameters.Add(m_database.CreateParameter("Temporary", asset.Temporary));
  252. cmd.Parameters.Add(m_database.CreateParameter("CreateTime", now));
  253. cmd.Parameters.Add(m_database.CreateParameter("AccessTime", now));
  254. cmd.Parameters.Add(m_database.CreateParameter("CreatorID", asset.Metadata.CreatorID));
  255. cmd.Parameters.Add(m_database.CreateParameter("AssetFlags", (int)asset.Flags));
  256. cmd.ExecuteNonQuery();
  257. }
  258. }
  259. catch (Exception e)
  260. {
  261. m_log.ErrorFormat("[ASSET DB]: PGSQL failure creating asset metadata {0} with name \"{1}\". Error: {2}",
  262. asset.FullID, asset.Name, e.Message);
  263. transaction.Rollback();
  264. return;
  265. }
  266. if (!ExistsData(dbcon, transaction, hash))
  267. {
  268. try
  269. {
  270. using (NpgsqlCommand cmd =
  271. new NpgsqlCommand(
  272. @"INSERT INTO XAssetsData(hash, data) VALUES(:Hash, :Data)",
  273. dbcon))
  274. {
  275. cmd.Parameters.Add(m_database.CreateParameter("Hash", hash));
  276. cmd.Parameters.Add(m_database.CreateParameter("Data", asset.Data));
  277. cmd.ExecuteNonQuery();
  278. }
  279. }
  280. catch (Exception e)
  281. {
  282. m_log.ErrorFormat("[XASSET DB]: PGSQL failure creating asset data {0} with name \"{1}\". Error: {2}",
  283. asset.FullID, asset.Name, e.Message);
  284. transaction.Rollback();
  285. return;
  286. }
  287. }
  288. transaction.Commit();
  289. }
  290. }
  291. }
  292. }
  293. /// <summary>
  294. /// Updates the access time of the asset if it was accessed above a given threshhold amount of time.
  295. /// </summary>
  296. /// <remarks>
  297. /// This gives us some insight into assets which haven't ben accessed for a long period. This is only done
  298. /// over the threshold time to avoid excessive database writes as assets are fetched.
  299. /// </remarks>
  300. /// <param name='asset'></param>
  301. /// <param name='accessTime'></param>
  302. private void UpdateAccessTime(AssetMetadata assetMetadata, int accessTime)
  303. {
  304. DateTime now = DateTime.UtcNow;
  305. if ((now - Utils.UnixTimeToDateTime(accessTime)).TotalDays < DaysBetweenAccessTimeUpdates)
  306. return;
  307. lock (m_dbLock)
  308. {
  309. using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
  310. {
  311. dbcon.Open();
  312. NpgsqlCommand cmd =
  313. new NpgsqlCommand(@"update XAssetsMeta set access_time=:AccessTime where id=:ID", dbcon);
  314. try
  315. {
  316. UUID asset_id;
  317. UUID.TryParse(assetMetadata.ID, out asset_id);
  318. using (cmd)
  319. {
  320. // create unix epoch time
  321. cmd.Parameters.Add(m_database.CreateParameter("id", asset_id));
  322. cmd.Parameters.Add(m_database.CreateParameter("access_time", (int)Utils.DateTimeToUnixTime(now)));
  323. cmd.ExecuteNonQuery();
  324. }
  325. }
  326. catch (Exception e)
  327. {
  328. m_log.ErrorFormat(
  329. "[XASSET PGSQL DB]: Failure updating access_time for asset {0} with name {1} : {2}",
  330. assetMetadata.ID, assetMetadata.Name, e.Message);
  331. }
  332. }
  333. }
  334. }
  335. /// <summary>
  336. /// We assume we already have the m_dbLock.
  337. /// </summary>
  338. /// TODO: need to actually use the transaction.
  339. /// <param name="dbcon"></param>
  340. /// <param name="transaction"></param>
  341. /// <param name="hash"></param>
  342. /// <returns></returns>
  343. private bool ExistsData(NpgsqlConnection dbcon, NpgsqlTransaction transaction, byte[] hash)
  344. {
  345. // m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid);
  346. bool exists = false;
  347. using (NpgsqlCommand cmd = new NpgsqlCommand(@"SELECT hash FROM XAssetsData WHERE hash=:Hash", dbcon))
  348. {
  349. cmd.Parameters.Add(m_database.CreateParameter("Hash", hash));
  350. try
  351. {
  352. using (NpgsqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
  353. {
  354. if (dbReader.Read())
  355. {
  356. // m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid);
  357. exists = true;
  358. }
  359. }
  360. }
  361. catch (Exception e)
  362. {
  363. m_log.ErrorFormat(
  364. "[XASSETS DB]: PGSql failure in ExistsData fetching hash {0}. Exception {1}{2}",
  365. hash, e.Message, e.StackTrace);
  366. }
  367. }
  368. return exists;
  369. }
  370. /// <summary>
  371. /// Check if the assets exist in the database.
  372. /// </summary>
  373. /// <param name="uuids">The assets' IDs</param>
  374. /// <returns>For each asset: true if it exists, false otherwise</returns>
  375. public bool[] AssetsExist(UUID[] uuids)
  376. {
  377. if (uuids.Length == 0)
  378. return new bool[0];
  379. HashSet<UUID> exist = new HashSet<UUID>();
  380. string ids = "'" + string.Join("','", uuids) + "'";
  381. string sql = string.Format(@"SELECT id FROM XAssetsMeta WHERE id IN ({0})", ids);
  382. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  383. {
  384. conn.Open();
  385. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  386. {
  387. using (NpgsqlDataReader reader = cmd.ExecuteReader())
  388. {
  389. while (reader.Read())
  390. {
  391. UUID id = DBGuid.FromDB(reader["id"]);
  392. exist.Add(id);
  393. }
  394. }
  395. }
  396. }
  397. bool[] results = new bool[uuids.Length];
  398. for (int i = 0; i < uuids.Length; i++)
  399. results[i] = exist.Contains(uuids[i]);
  400. return results;
  401. }
  402. /// <summary>
  403. /// Check if the asset exists in the database
  404. /// </summary>
  405. /// <param name="uuid">The asset UUID</param>
  406. /// <returns>true if it exists, false otherwise.</returns>
  407. public bool ExistsAsset(UUID uuid)
  408. {
  409. // m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid);
  410. bool assetExists = false;
  411. lock (m_dbLock)
  412. {
  413. using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
  414. {
  415. dbcon.Open();
  416. using (NpgsqlCommand cmd = new NpgsqlCommand(@"SELECT id FROM XAssetsMeta WHERE id=:ID", dbcon))
  417. {
  418. cmd.Parameters.Add(m_database.CreateParameter("id", uuid));
  419. try
  420. {
  421. using (NpgsqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
  422. {
  423. if (dbReader.Read())
  424. {
  425. // m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid);
  426. assetExists = true;
  427. }
  428. }
  429. }
  430. catch (Exception e)
  431. {
  432. m_log.Error(string.Format("[XASSETS DB]: PGSql failure fetching asset {0}", uuid), e);
  433. }
  434. }
  435. }
  436. }
  437. return assetExists;
  438. }
  439. /// <summary>
  440. /// Returns a list of AssetMetadata objects. The list is a subset of
  441. /// the entire data set offset by <paramref name="start" /> containing
  442. /// <paramref name="count" /> elements.
  443. /// </summary>
  444. /// <param name="start">The number of results to discard from the total data set.</param>
  445. /// <param name="count">The number of rows the returned list should contain.</param>
  446. /// <returns>A list of AssetMetadata objects.</returns>
  447. public List<AssetMetadata> FetchAssetMetadataSet(int start, int count)
  448. {
  449. List<AssetMetadata> retList = new List<AssetMetadata>(count);
  450. lock (m_dbLock)
  451. {
  452. using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
  453. {
  454. dbcon.Open();
  455. using(NpgsqlCommand cmd = new NpgsqlCommand(@"SELECT name, description, access_time, ""AssetType"", temporary, id, asset_flags, creatorid
  456. FROM XAssetsMeta
  457. LIMIT :start, :count",dbcon))
  458. {
  459. cmd.Parameters.Add(m_database.CreateParameter("start",start));
  460. cmd.Parameters.Add(m_database.CreateParameter("count", count));
  461. try
  462. {
  463. using (NpgsqlDataReader dbReader = cmd.ExecuteReader())
  464. {
  465. while (dbReader.Read())
  466. {
  467. AssetMetadata metadata = new AssetMetadata();
  468. metadata.Name = (string)dbReader["name"];
  469. metadata.Description = (string)dbReader["description"];
  470. metadata.Type = Convert.ToSByte(dbReader["AssetType"]);
  471. metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]);
  472. metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]);
  473. metadata.FullID = DBGuid.FromDB(dbReader["id"]);
  474. metadata.CreatorID = dbReader["creatorid"].ToString();
  475. // We'll ignore this for now - it appears unused!
  476. // metadata.SHA1 = dbReader["hash"]);
  477. UpdateAccessTime(metadata, (int)dbReader["access_time"]);
  478. retList.Add(metadata);
  479. }
  480. }
  481. }
  482. catch (Exception e)
  483. {
  484. m_log.Error("[XASSETS DB]: PGSql failure fetching asset set" + Environment.NewLine + e.ToString());
  485. }
  486. }
  487. }
  488. }
  489. return retList;
  490. }
  491. public bool Delete(string id)
  492. {
  493. // m_log.DebugFormat("[XASSETS DB]: Deleting asset {0}", id);
  494. lock (m_dbLock)
  495. {
  496. using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
  497. {
  498. dbcon.Open();
  499. using (NpgsqlCommand cmd = new NpgsqlCommand(@"delete from XAssetsMeta where id=:ID", dbcon))
  500. {
  501. cmd.Parameters.Add(m_database.CreateParameter(id, id));
  502. cmd.ExecuteNonQuery();
  503. }
  504. // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we
  505. // keep a reference count (?)
  506. }
  507. }
  508. return true;
  509. }
  510. #endregion
  511. }
  512. }