In the asset service, check that an asset exists before attempting to store it.
parent
ac7537d240
commit
9439a92202
|
@ -251,12 +251,14 @@ namespace OpenSim.Data.MySQL
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// check if the asset UUID exist in database
|
/// Check if the asset exists in the database
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uuid">The asset UUID</param>
|
/// <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)
|
override public bool ExistsAsset(UUID uuid)
|
||||||
{
|
{
|
||||||
|
// m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid);
|
||||||
|
|
||||||
bool assetExists = false;
|
bool assetExists = false;
|
||||||
|
|
||||||
lock (m_dbLock)
|
lock (m_dbLock)
|
||||||
|
@ -273,9 +275,12 @@ namespace OpenSim.Data.MySQL
|
||||||
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||||
{
|
{
|
||||||
if (dbReader.Read())
|
if (dbReader.Read())
|
||||||
|
{
|
||||||
|
// m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid);
|
||||||
assetExists = true;
|
assetExists = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat(
|
m_log.ErrorFormat(
|
||||||
|
|
|
@ -156,10 +156,12 @@ namespace OpenSim.Services.AssetService
|
||||||
|
|
||||||
public virtual string Store(AssetBase asset)
|
public virtual string Store(AssetBase asset)
|
||||||
{
|
{
|
||||||
|
if (!m_Database.ExistsAsset(asset.FullID))
|
||||||
|
{
|
||||||
// m_log.DebugFormat(
|
// 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);
|
m_Database.StoreAsset(asset);
|
||||||
|
}
|
||||||
|
|
||||||
return asset.ID;
|
return asset.ID;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue