aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-05-31 21:44:57 +0000
committerJustin Clarke Casey2008-05-31 21:44:57 +0000
commitd703e2004fb39ede3cb166db02fb8ccd790b5835 (patch)
tree202a5c9a8ab0b14c46cb01ceb780ff1839532266 /OpenSim/Data
parent* minor: comment out old debugging messages in task inventory item restoratio... (diff)
downloadopensim-SC-d703e2004fb39ede3cb166db02fb8ccd790b5835.zip
opensim-SC-d703e2004fb39ede3cb166db02fb8ccd790b5835.tar.gz
opensim-SC-d703e2004fb39ede3cb166db02fb8ccd790b5835.tar.bz2
opensim-SC-d703e2004fb39ede3cb166db02fb8ccd790b5835.tar.xz
* Change MySQL to check whether an asset already exists before inserting it into the database
Diffstat (limited to 'OpenSim/Data')
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs41
1 files changed, 40 insertions, 1 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index e556352..76f6307 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -114,6 +114,12 @@ namespace OpenSim.Data.MySQL
114 { 114 {
115 lock (_dbConnection) 115 lock (_dbConnection)
116 { 116 {
117 m_log.Info("[ASSET DB]: Creating Asset " + Util.ToRawUuidString(asset.FullID));
118 if (ExistsAsset(asset.FullID))
119 {
120 m_log.Info("[ASSET DB]: Asset exists already, ignoring.");
121 }
122
117 MySqlCommand cmd = 123 MySqlCommand cmd =
118 new MySqlCommand( 124 new MySqlCommand(
119 "REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" + 125 "REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" +
@@ -156,7 +162,40 @@ namespace OpenSim.Data.MySQL
156 162
157 override public bool ExistsAsset(LLUUID uuid) 163 override public bool ExistsAsset(LLUUID uuid)
158 { 164 {
159 throw new Exception("The method or operation is not implemented."); 165 bool assetExists = false;
166
167 lock (_dbConnection)
168 {
169 MySqlCommand cmd =
170 new MySqlCommand(
171 "SELECT id FROM assets WHERE id=?id",
172 _dbConnection.Connection);
173 MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16);
174 p.Value = uuid.GetBytes();
175
176 try
177 {
178 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
179 {
180 if (dbReader.Read())
181 {
182 assetExists = true;
183 }
184
185 dbReader.Close();
186 cmd.Dispose();
187 }
188 }
189 catch (Exception e)
190 {
191 m_log.ErrorFormat(
192 "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString()
193 + Environment.NewLine + "Attempting reconnection", uuid);
194 _dbConnection.Reconnect();
195 }
196 }
197
198 return assetExists;
160 } 199 }
161 200
162 /// <summary> 201 /// <summary>