From 92f9750dedf6b1de908aede7e04694d91c0c614c Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 2 Nov 2012 00:02:10 +0000 Subject: [PATCH] Move check to allow only deletion of maptiles up to AssetServerDeleteHandler from AssetService. This allows us to use a common check for both AssetService and XAssetService. It also allows future console commands to delete an asset. As before, deletion of maptile assets is not allowed remotely unless this is explicitly configured. --- .../Handlers/Asset/AssetServerDeleteHandler.cs | 17 ++++++++++++++--- OpenSim/Services/AssetService/AssetService.cs | 17 ++--------------- OpenSim/Services/AssetService/XAssetService.cs | 18 ++---------------- 3 files changed, 18 insertions(+), 34 deletions(-) diff --git a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs index 0cfe5b17de..9a8aee632c 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs @@ -44,7 +44,7 @@ namespace OpenSim.Server.Handlers.Asset { public class AssetServerDeleteHandler : BaseStreamHandler { - // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IAssetService m_AssetService; protected bool m_allowDelete; @@ -65,11 +65,22 @@ namespace OpenSim.Server.Handlers.Asset if (p.Length > 0 && m_allowDelete) { - result = m_AssetService.Delete(p[0]); + string assetID = p[0]; + + AssetBase asset = m_AssetService.Get(assetID); + if (asset != null && (int)(asset.Flags & AssetFlags.Maptile) != 0) + { + result = m_AssetService.Delete(assetID); + } + else + { + m_log.DebugFormat( + "[ASSET SERVER DELETE HANDLER]: Request to delete asset {0}, but flags are not Maptile", assetID); + } } XmlSerializer xs = new XmlSerializer(typeof(bool)); return ServerUtils.SerializeResult(xs, result); } } -} +} \ No newline at end of file diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs index b1f0f7e84d..e7eb6fe924 100644 --- a/OpenSim/Services/AssetService/AssetService.cs +++ b/OpenSim/Services/AssetService/AssetService.cs @@ -70,7 +70,7 @@ namespace OpenSim.Services.AssetService if (assetLoaderEnabled) { - m_log.DebugFormat("[ASSET]: Loading default asset set from {0}", loaderArgs); + m_log.DebugFormat("[ASSET SERVICE]: Loading default asset set from {0}", loaderArgs); m_AssetLoader.ForEachDefaultXmlAsset( loaderArgs, @@ -197,20 +197,7 @@ namespace OpenSim.Services.AssetService if (!UUID.TryParse(id, out assetID)) return false; - AssetBase asset = m_Database.GetAsset(assetID); - if (asset == null) - return false; - - if ((int)(asset.Flags & AssetFlags.Maptile) != 0) - { - return m_Database.Delete(id); - } - else - { - m_log.DebugFormat("[ASSET SERVICE]: Request to delete asset {0}, but flags are not Maptile", id); - } - - return false; + return m_Database.Delete(id); } } } \ No newline at end of file diff --git a/OpenSim/Services/AssetService/XAssetService.cs b/OpenSim/Services/AssetService/XAssetService.cs index e62bcb556d..a1d10ed5c5 100644 --- a/OpenSim/Services/AssetService/XAssetService.cs +++ b/OpenSim/Services/AssetService/XAssetService.cs @@ -194,21 +194,7 @@ namespace OpenSim.Services.AssetService if (!UUID.TryParse(id, out assetID)) return false; - AssetBase asset = m_Database.GetAsset(assetID); - if (asset == null) - return false; - - if ((int)(asset.Flags & AssetFlags.Maptile) != 0) - { - return m_Database.Delete(id); - } - else - { - m_log.DebugFormat("[XASSET SERVICE]: Request to delete asset {0}, but flags are not Maptile", id); - } - - return false; + return m_Database.Delete(id); } } -} - +} \ No newline at end of file