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.
0.7.4-extended
Justin Clark-Casey (justincc) 2012-11-02 00:02:10 +00:00
parent 23106bce76
commit 92f9750ded
3 changed files with 18 additions and 34 deletions

View File

@ -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);
}
}
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}
}