Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move check to allow only deletion of maptiles up to AssetServerDelete…

…Handler 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.
  • Loading branch information...
commit 462ad336dcd59dfc4325aed9e6d635aa866cd094 1 parent 8dfe59d
Justin Clark-Casey justincc authored
17 OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs
View
@@ -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 @@ public class AssetServerDeleteHandler : BaseStreamHandler
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);
}
}
-}
+}
17 OpenSim/Services/AssetService/AssetService.cs
View
@@ -70,7 +70,7 @@ public AssetService(IConfigSource config, string configName) : base(config, conf
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 @@ public virtual bool Delete(string id)
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);
}
}
}
18 OpenSim/Services/AssetService/XAssetService.cs
View
@@ -194,21 +194,7 @@ public virtual bool Delete(string id)
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);
}
}
-}
-
+}
Please sign in to comment.
Something went wrong with that request. Please try again.