From 6b51d8a10e44eed7c39b58aab256789ab188ecca Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 17 Aug 2011 23:24:41 +0100 Subject: In the asset service, check that an asset exists before attempting to store it. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 9 +++++++-- OpenSim/Services/AssetService/AssetService.cs | 10 ++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index e740232..a743479 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -251,12 +251,14 @@ namespace OpenSim.Data.MySQL } /// - /// check if the asset UUID exist in database + /// Check if the asset exists in the database /// /// The asset UUID - /// true if exist. + /// true if it exists, false otherwise. override public bool ExistsAsset(UUID uuid) { +// m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid); + bool assetExists = false; lock (m_dbLock) @@ -273,7 +275,10 @@ 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) diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs index c7a259d..d40aa4b 100644 --- a/OpenSim/Services/AssetService/AssetService.cs +++ b/OpenSim/Services/AssetService/AssetService.cs @@ -174,10 +174,12 @@ namespace OpenSim.Services.AssetService public virtual string Store(AssetBase asset) { -// m_log.DebugFormat( -// "[ASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.ID, asset.Data.Length); - - m_Database.StoreAsset(asset); + if (!m_Database.ExistsAsset(asset.FullID)) + { +// m_log.DebugFormat( +// "[ASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.FullID, asset.Data.Length); + m_Database.StoreAsset(asset); + } return asset.ID; } -- cgit v1.1