diff options
author | Sean Dague | 2008-01-14 21:35:49 +0000 |
---|---|---|
committer | Sean Dague | 2008-01-14 21:35:49 +0000 |
commit | b49ae37e89340c5ec5bbafcfd462fc7d6815f34b (patch) | |
tree | 2d384004e8a07a9c0f8cf9150092154ba39b38c6 /OpenSim | |
parent | good bye ADO.NET to assets, notice faster startup time (diff) | |
download | opensim-SC-b49ae37e89340c5ec5bbafcfd462fc7d6815f34b.zip opensim-SC-b49ae37e89340c5ec5bbafcfd462fc7d6815f34b.tar.gz opensim-SC-b49ae37e89340c5ec5bbafcfd462fc7d6815f34b.tar.bz2 opensim-SC-b49ae37e89340c5ec5bbafcfd462fc7d6815f34b.tar.xz |
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.
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs b/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs index 7b02e99..e2b28cd 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs | |||
@@ -57,7 +57,6 @@ namespace OpenSim.Framework.Data.SQLite | |||
57 | { | 57 | { |
58 | m_conn = new SqliteConnection("URI=file:" + dbfile + ",version=3"); | 58 | m_conn = new SqliteConnection("URI=file:" + dbfile + ",version=3"); |
59 | m_conn.Open(); | 59 | m_conn.Open(); |
60 | |||
61 | TestTables(m_conn); | 60 | TestTables(m_conn); |
62 | return; | 61 | return; |
63 | } | 62 | } |
@@ -70,13 +69,15 @@ namespace OpenSim.Framework.Data.SQLite | |||
70 | cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.UUID.ToString())); | 69 | cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.UUID.ToString())); |
71 | using (IDataReader reader = cmd.ExecuteReader()) | 70 | using (IDataReader reader = cmd.ExecuteReader()) |
72 | { | 71 | { |
73 | reader.Read(); | 72 | if (reader.Read()) |
74 | if (reader != null) | ||
75 | { | 73 | { |
76 | return buildAsset(reader); | 74 | AssetBase asset = buildAsset(reader); |
75 | reader.Close(); | ||
76 | return asset; | ||
77 | } | 77 | } |
78 | else | 78 | else |
79 | { | 79 | { |
80 | reader.Close(); | ||
80 | return null; | 81 | return null; |
81 | } | 82 | } |
82 | } | 83 | } |
@@ -85,8 +86,10 @@ namespace OpenSim.Framework.Data.SQLite | |||
85 | 86 | ||
86 | public void CreateAsset(AssetBase asset) | 87 | public void CreateAsset(AssetBase asset) |
87 | { | 88 | { |
89 | MainLog.Instance.Verbose("SQLITE", "Creating Asset " + asset.FullID.UUID.ToString()); | ||
88 | if (ExistsAsset(asset.FullID)) | 90 | if (ExistsAsset(asset.FullID)) |
89 | { | 91 | { |
92 | MainLog.Instance.Verbose("SQLITE", "Asset exists, updating instead. You should fix the caller for this!"); | ||
90 | UpdateAsset(asset); | 93 | UpdateAsset(asset); |
91 | } | 94 | } |
92 | else | 95 | else |
@@ -140,7 +143,23 @@ namespace OpenSim.Framework.Data.SQLite | |||
140 | 143 | ||
141 | public bool ExistsAsset(LLUUID uuid) | 144 | public bool ExistsAsset(LLUUID uuid) |
142 | { | 145 | { |
143 | return (FetchAsset(uuid) != null); | 146 | using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn)) |
147 | { | ||
148 | cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.UUID.ToString())); | ||
149 | using (IDataReader reader = cmd.ExecuteReader()) | ||
150 | { | ||
151 | if(reader.Read()) | ||
152 | { | ||
153 | reader.Close(); | ||
154 | return true; | ||
155 | } | ||
156 | else | ||
157 | { | ||
158 | reader.Close(); | ||
159 | return false; | ||
160 | } | ||
161 | } | ||
162 | } | ||
144 | } | 163 | } |
145 | 164 | ||
146 | public void DeleteAsset(LLUUID uuid) | 165 | public void DeleteAsset(LLUUID uuid) |