Merge branch 'master' into careminster-presence-refactor
commit
6a3e1734e6
|
@ -48,5 +48,6 @@ namespace OpenSim.Data
|
|||
public abstract void Initialise(string connect);
|
||||
public abstract void Initialise();
|
||||
public abstract void Dispose();
|
||||
public abstract bool Delete(string id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ namespace OpenSim.Data
|
|||
bool ExistsAsset(UUID uuid);
|
||||
List<AssetMetadata> FetchAssetMetadataSet(int start, int count);
|
||||
void Initialise(string connect);
|
||||
bool Delete(string id);
|
||||
}
|
||||
|
||||
public class AssetDataInitialiser : PluginInitialiserBase
|
||||
|
|
|
@ -322,6 +322,10 @@ namespace OpenSim.Data.MSSQL
|
|||
return retList;
|
||||
}
|
||||
|
||||
public override bool Delete(string id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -338,6 +338,24 @@ namespace OpenSim.Data.MySQL
|
|||
return retList;
|
||||
}
|
||||
|
||||
public override bool Delete(string id)
|
||||
{
|
||||
lock (m_dbLock)
|
||||
{
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
{
|
||||
dbcon.Open();
|
||||
MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id");
|
||||
cmd.Parameters.AddWithValue("?id", id);
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -207,20 +207,6 @@ namespace OpenSim.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete an asset from database
|
||||
/// </summary>
|
||||
/// <param name="uuid"></param>
|
||||
public void DeleteAsset(UUID uuid)
|
||||
{
|
||||
using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn))
|
||||
{
|
||||
cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString()));
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
@ -338,6 +324,26 @@ namespace OpenSim.Data.SQLite
|
|||
get { return "SQLite Asset storage engine"; }
|
||||
}
|
||||
|
||||
public override bool Delete(string id)
|
||||
{
|
||||
UUID assetID;
|
||||
|
||||
if (!UUID.TryParse(id, out assetID))
|
||||
return false;
|
||||
|
||||
lock (this)
|
||||
{
|
||||
using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn))
|
||||
{
|
||||
cmd.Parameters.Add(new SqliteParameter(":UUID", assetID.ToString()));
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -338,6 +338,10 @@ namespace OpenSim.Data.SQLiteLegacy
|
|||
get { return "SQLite Asset storage engine"; }
|
||||
}
|
||||
|
||||
public override bool Delete(string id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,9 +59,11 @@ namespace OpenSim.Server.Handlers.Asset
|
|||
m_AssetService =
|
||||
ServerUtils.LoadPlugin<IAssetService>(assetService, args);
|
||||
|
||||
bool allowDelete = serverConfig.GetBoolean("AllowRemoteDelete", false);
|
||||
|
||||
server.AddStreamHandler(new AssetServerGetHandler(m_AssetService));
|
||||
server.AddStreamHandler(new AssetServerPostHandler(m_AssetService));
|
||||
server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService));
|
||||
server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowDelete));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,11 +47,13 @@ namespace OpenSim.Server.Handlers.Asset
|
|||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private IAssetService m_AssetService;
|
||||
protected bool m_allowDelete;
|
||||
|
||||
public AssetServerDeleteHandler(IAssetService service) :
|
||||
public AssetServerDeleteHandler(IAssetService service, bool allowDelete) :
|
||||
base("DELETE", "/assets")
|
||||
{
|
||||
m_AssetService = service;
|
||||
m_allowDelete = allowDelete;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request,
|
||||
|
@ -61,9 +63,9 @@ namespace OpenSim.Server.Handlers.Asset
|
|||
|
||||
string[] p = SplitParams(path);
|
||||
|
||||
if (p.Length > 0)
|
||||
if (p.Length > 0 && m_allowDelete)
|
||||
{
|
||||
// result = m_AssetService.Delete(p[0]);
|
||||
result = m_AssetService.Delete(p[0]);
|
||||
}
|
||||
|
||||
XmlSerializer xs = new XmlSerializer(typeof(bool));
|
||||
|
|
|
@ -156,6 +156,17 @@ namespace OpenSim.Services.AssetService
|
|||
|
||||
public bool Delete(string id)
|
||||
{
|
||||
UUID assetID;
|
||||
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);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,5 +60,10 @@ namespace OpenSim.Tests.Common.Mock
|
|||
}
|
||||
|
||||
public List<AssetMetadata> FetchAssetMetadataSet(int start, int count) { return new List<AssetMetadata>(count); }
|
||||
|
||||
public bool Delete(string id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
|
|||
LocalServiceModule = "OpenSim.Services.AssetService.dll:AssetService"
|
||||
DefaultAssetLoader = "OpenSim.Framework.AssetLoader.Filesystem.dll"
|
||||
AssetLoaderArgs = "assets/AssetSets.xml"
|
||||
AllowRemoteDelete = "false"
|
||||
|
||||
; * This configuration loads the inventory server modules. It duplicates
|
||||
; * the function of the legacy inventory server
|
||||
|
|
Loading…
Reference in New Issue