In the asset service, check that an asset exists before attempting to store it.

bulletsim
Justin Clark-Casey (justincc) 2011-08-17 23:24:41 +01:00
parent 4a9b8184f7
commit 6b51d8a10e
2 changed files with 13 additions and 6 deletions

View File

@ -251,12 +251,14 @@ namespace OpenSim.Data.MySQL
}
/// <summary>
/// check if the asset UUID exist in database
/// Check if the asset exists in the database
/// </summary>
/// <param name="uuid">The asset UUID</param>
/// <returns>true if exist.</returns>
/// <returns>true if it exists, false otherwise.</returns>
override public bool ExistsAsset(UUID uuid)
{
// m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid);
bool assetExists = false;
lock (m_dbLock)
@ -273,9 +275,12 @@ namespace OpenSim.Data.MySQL
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
{
if (dbReader.Read())
{
// m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid);
assetExists = true;
}
}
}
catch (Exception e)
{
m_log.ErrorFormat(

View File

@ -174,10 +174,12 @@ namespace OpenSim.Services.AssetService
public virtual string Store(AssetBase asset)
{
if (!m_Database.ExistsAsset(asset.FullID))
{
// m_log.DebugFormat(
// "[ASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.ID, asset.Data.Length);
// "[ASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.FullID, asset.Data.Length);
m_Database.StoreAsset(asset);
}
return asset.ID;
}