aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/PGSQL/PGSQLAssetData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/PGSQL/PGSQLAssetData.cs')
-rw-r--r--OpenSim/Data/PGSQL/PGSQLAssetData.cs43
1 files changed, 32 insertions, 11 deletions
diff --git a/OpenSim/Data/PGSQL/PGSQLAssetData.cs b/OpenSim/Data/PGSQL/PGSQLAssetData.cs
index 7c5c01d..81adb03 100644
--- a/OpenSim/Data/PGSQL/PGSQLAssetData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLAssetData.cs
@@ -166,18 +166,18 @@ namespace OpenSim.Data.PGSQL
166 "; 166 ";
167 167
168 string assetName = asset.Name; 168 string assetName = asset.Name;
169 if (asset.Name.Length > 64) 169 if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
170 { 170 {
171 assetName = asset.Name.Substring(0, 64); 171 assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
172 m_log.WarnFormat( 172 m_log.WarnFormat(
173 "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", 173 "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
174 asset.Name, asset.ID, asset.Name.Length, assetName.Length); 174 asset.Name, asset.ID, asset.Name.Length, assetName.Length);
175 } 175 }
176 176
177 string assetDescription = asset.Description; 177 string assetDescription = asset.Description;
178 if (asset.Description.Length > 64) 178 if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
179 { 179 {
180 assetDescription = asset.Description.Substring(0, 64); 180 assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
181 m_log.WarnFormat( 181 m_log.WarnFormat(
182 "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", 182 "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
183 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); 183 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
@@ -232,17 +232,38 @@ namespace OpenSim.Data.PGSQL
232// } 232// }
233 233
234 /// <summary> 234 /// <summary>
235 /// Check if asset exist in m_database 235 /// Check if the assets exist in the database.
236 /// </summary> 236 /// </summary>
237 /// <param name="uuid"></param> 237 /// <param name="uuids">The assets' IDs</param>
238 /// <returns>true if exist.</returns> 238 /// <returns>For each asset: true if it exists, false otherwise</returns>
239 override public bool ExistsAsset(UUID uuid) 239 public override bool[] AssetsExist(UUID[] uuids)
240 { 240 {
241 if (GetAsset(uuid) != null) 241 if (uuids.Length == 0)
242 return new bool[0];
243
244 HashSet<UUID> exist = new HashSet<UUID>();
245
246 string ids = "'" + string.Join("','", uuids) + "'";
247 string sql = string.Format("SELECT id FROM assets WHERE id IN ({0})", ids);
248
249 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
250 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
242 { 251 {
243 return true; 252 conn.Open();
253 using (NpgsqlDataReader reader = cmd.ExecuteReader())
254 {
255 while (reader.Read())
256 {
257 UUID id = DBGuid.FromDB(reader["id"]);
258 exist.Add(id);
259 }
260 }
244 } 261 }
245 return false; 262
263 bool[] results = new bool[uuids.Length];
264 for (int i = 0; i < uuids.Length; i++)
265 results[i] = exist.Contains(uuids[i]);
266 return results;
246 } 267 }
247 268
248 /// <summary> 269 /// <summary>