my Exists check was slow and wrong. This fixes issues people
were just having on IRC. Thanks to Grumly57 for helping to sort this out.ThreadPoolClientBranch
parent
20cf62b417
commit
b49ae37e89
|
@ -57,7 +57,6 @@ namespace OpenSim.Framework.Data.SQLite
|
||||||
{
|
{
|
||||||
m_conn = new SqliteConnection("URI=file:" + dbfile + ",version=3");
|
m_conn = new SqliteConnection("URI=file:" + dbfile + ",version=3");
|
||||||
m_conn.Open();
|
m_conn.Open();
|
||||||
|
|
||||||
TestTables(m_conn);
|
TestTables(m_conn);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -70,13 +69,15 @@ namespace OpenSim.Framework.Data.SQLite
|
||||||
cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.UUID.ToString()));
|
cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.UUID.ToString()));
|
||||||
using (IDataReader reader = cmd.ExecuteReader())
|
using (IDataReader reader = cmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
reader.Read();
|
if (reader.Read())
|
||||||
if (reader != null)
|
|
||||||
{
|
{
|
||||||
return buildAsset(reader);
|
AssetBase asset = buildAsset(reader);
|
||||||
|
reader.Close();
|
||||||
|
return asset;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
reader.Close();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,8 +86,10 @@ namespace OpenSim.Framework.Data.SQLite
|
||||||
|
|
||||||
public void CreateAsset(AssetBase asset)
|
public void CreateAsset(AssetBase asset)
|
||||||
{
|
{
|
||||||
|
MainLog.Instance.Verbose("SQLITE", "Creating Asset " + asset.FullID.UUID.ToString());
|
||||||
if (ExistsAsset(asset.FullID))
|
if (ExistsAsset(asset.FullID))
|
||||||
{
|
{
|
||||||
|
MainLog.Instance.Verbose("SQLITE", "Asset exists, updating instead. You should fix the caller for this!");
|
||||||
UpdateAsset(asset);
|
UpdateAsset(asset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -140,7 +143,23 @@ namespace OpenSim.Framework.Data.SQLite
|
||||||
|
|
||||||
public bool ExistsAsset(LLUUID uuid)
|
public bool ExistsAsset(LLUUID uuid)
|
||||||
{
|
{
|
||||||
return (FetchAsset(uuid) != null);
|
using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn))
|
||||||
|
{
|
||||||
|
cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.UUID.ToString()));
|
||||||
|
using (IDataReader reader = cmd.ExecuteReader())
|
||||||
|
{
|
||||||
|
if(reader.Read())
|
||||||
|
{
|
||||||
|
reader.Close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reader.Close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteAsset(LLUUID uuid)
|
public void DeleteAsset(LLUUID uuid)
|
||||||
|
|
Loading…
Reference in New Issue