A better purge of trash folder.

arthursv
Diva Canto 2009-08-19 00:13:51 -07:00
parent e5f33e7505
commit c5af39239f
20 changed files with 107 additions and 54 deletions

View File

@ -851,7 +851,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
// Delete the old item
Rest.InventoryServices.DeleteItem(uri);
List<UUID> uuids = new List<UUID>();
uuids.Add(uri.ID);
Rest.InventoryServices.DeleteItems(uri.Owner, uuids);
// Add the new item to the inventory
@ -927,7 +929,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
InventoryItemBase item = (InventoryItemBase) InventoryNode;
Rest.Log.DebugFormat("{0} {1}: Item {2} will be deleted",
MsgId, rdata.method, rdata.path);
Rest.InventoryServices.DeleteItem(item);
List<UUID> uuids = new List<UUID>();
uuids.Add(item.ID);
Rest.InventoryServices.DeleteItems(item.Owner, uuids);
rdata.appendStatus(String.Format("<p>Deleted item {0} UUID {1} <p>", item.Name, item.ID));
}

View File

@ -653,7 +653,9 @@ namespace OpenSim.Framework.Communications.Cache
if (RootFolder.DeleteItem(item.ID))
{
return m_InventoryService.DeleteItem(item);
List<UUID> uuids = new List<UUID>();
uuids.Add(itemID);
return m_InventoryService.DeleteItems(this.UserProfile.ID, uuids);
}
}
else

View File

@ -547,7 +547,7 @@ namespace OpenSim.Framework.Communications.Tests
return false;
}
public bool DeleteItem(InventoryItemBase item)
public bool DeleteItems(UUID owner, List<UUID> items)
{
return false;
}

View File

@ -257,7 +257,7 @@ namespace OpenSim.Framework
IClientAPI remoteClient, UUID folderID, UUID itemID, int length, string newName);
public delegate void RemoveInventoryItem(
IClientAPI remoteClient, UUID itemID);
IClientAPI remoteClient, List<UUID> itemIDs);
public delegate void RemoveInventoryFolder(
IClientAPI remoteClient, UUID folderID);

View File

@ -7053,14 +7053,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (OnRemoveInventoryItem != null)
{
handlerRemoveInventoryItem = null;
List<UUID> uuids = new List<UUID>();
foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData)
{
handlerRemoveInventoryItem = OnRemoveInventoryItem;
if (handlerRemoveInventoryItem != null)
{
handlerRemoveInventoryItem(this, datablock.ItemID);
}
uuids.Add(datablock.ItemID);
}
handlerRemoveInventoryItem = OnRemoveInventoryItem;
if (handlerRemoveInventoryItem != null)
{
handlerRemoveInventoryItem(this, uuids);
}
}
break;
case PacketType.RemoveInventoryFolder:
@ -7116,13 +7119,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (OnRemoveInventoryItem != null)
{
handlerRemoveInventoryItem = null;
List<UUID> uuids = new List<UUID>();
foreach (RemoveInventoryObjectsPacket.ItemDataBlock datablock in removeObject.ItemData)
{
handlerRemoveInventoryItem = OnRemoveInventoryItem;
if (handlerRemoveInventoryItem != null)
{
handlerRemoveInventoryItem(this, datablock.ItemID);
}
uuids.Add(datablock.ItemID);
}
handlerRemoveInventoryItem = OnRemoveInventoryItem;
if (handlerRemoveInventoryItem != null)
{
handlerRemoveInventoryItem(this, uuids);
}
}
break;

View File

@ -267,7 +267,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
item.Folder = trashFolder.ID;
// Diva comment: can't we just update this item???
invService.DeleteItem(item);
List<UUID> uuids = new List<UUID>();
uuids.Add(item.ID);
invService.DeleteItems(item.Owner, uuids);
scene.AddInventoryItem(client, item);
}
else

View File

@ -186,7 +186,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
/// </summary>
/// <param name="item"></param>
/// <returns>true if the item was successfully deleted</returns>
public abstract bool DeleteItem(InventoryItemBase item);
public abstract bool DeleteItems(UUID ownerID, List<UUID> itemIDs);
public abstract InventoryItemBase GetItem(InventoryItemBase item);

View File

@ -393,18 +393,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
}
}
public override bool DeleteItem(InventoryItemBase item)
public override bool DeleteItems(UUID ownerID, List<UUID> itemIDs)
{
if (item == null)
return false;
m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Delete {0} items for user {1}", itemIDs.Count, ownerID);
if (IsLocalGridUser(item.Owner))
return m_GridService.DeleteItem(item);
if (itemIDs == null)
return false;
if (itemIDs.Count == 0)
return true;
if (IsLocalGridUser(ownerID))
return m_GridService.DeleteItems(ownerID, itemIDs);
else
{
UUID sessionID = GetSessionID(item.Owner);
string uri = GetUserInventoryURI(item.Owner) + "/" + item.Owner.ToString();
return m_HGService.DeleteItem(uri, item, sessionID);
UUID sessionID = GetSessionID(ownerID);
string uri = GetUserInventoryURI(ownerID) + "/" + ownerID.ToString();
return m_HGService.DeleteItems(uri, itemIDs, sessionID);
}
}

View File

@ -294,9 +294,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
/// </summary>
/// <param name="item"></param>
/// <returns>true if the item was successfully deleted</returns>
public override bool DeleteItem(InventoryItemBase item)
public override bool DeleteItems(UUID ownerID, List<UUID> itemIDs)
{
return m_InventoryService.DeleteItem(item);
return m_InventoryService.DeleteItems(ownerID, itemIDs);
}
public override InventoryItemBase GetItem(InventoryItemBase item)

View File

@ -273,13 +273,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
return m_RemoteConnector.UpdateItem(item.Owner.ToString(), item, sessionID);
}
public override bool DeleteItem(InventoryItemBase item)
public override bool DeleteItems(UUID ownerID, List<UUID> itemIDs)
{
if (item == null)
if (itemIDs == null)
return false;
if (itemIDs.Count == 0)
return true;
UUID sessionID = GetSessionID(item.Owner);
return m_RemoteConnector.DeleteItem(item.Owner.ToString(), item, sessionID);
UUID sessionID = GetSessionID(ownerID);
return m_RemoteConnector.DeleteItems(ownerID.ToString(), itemIDs, sessionID);
}
public override InventoryItemBase GetItem(InventoryItemBase item)

View File

@ -477,7 +477,11 @@ namespace OpenSim.Region.Framework.Scenes
if (!Permissions.BypassPermissions())
{
if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
InventoryService.DeleteItem(new InventoryItemBase(itemId));
{
List<UUID> items = new List<UUID>();
items.Add(itemId);
InventoryService.DeleteItems(senderId, items);
}
}
return itemCopy;
@ -652,7 +656,9 @@ namespace OpenSim.Region.Framework.Scenes
item.Folder = folderID;
// Diva comment: can't we just update?
InventoryService.DeleteItem(item);
List<UUID> uuids = new List<UUID>();
uuids.Add(item.ID);
InventoryService.DeleteItems(item.Owner, uuids);
AddInventoryItem(remoteClient, item);
}
@ -799,9 +805,10 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="itemID"></param>
private void RemoveInventoryItem(IClientAPI remoteClient, UUID itemID)
private void RemoveInventoryItem(IClientAPI remoteClient, List<UUID> itemIDs)
{
InventoryService.DeleteItem(new InventoryItemBase(itemID));
//m_log.Debug("[SCENE INVENTORY]: user " + remoteClient.AgentId);
InventoryService.DeleteItems(remoteClient.AgentId, itemIDs);
}
/// <summary>
@ -1248,7 +1255,11 @@ namespace OpenSim.Region.Framework.Scenes
if (!Permissions.BypassPermissions())
{
if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
RemoveInventoryItem(remoteClient, itemID);
{
List<UUID> uuids = new List<UUID>();
uuids.Add(itemID);
RemoveInventoryItem(remoteClient, uuids);
}
}
}
else
@ -2144,7 +2155,11 @@ namespace OpenSim.Region.Framework.Scenes
// copy ones will be lost, so avoid it
//
if (!attachment)
InventoryService.DeleteItem(item);
{
List<UUID> uuids = new List<UUID>();
uuids.Add(item.ID);
InventoryService.DeleteItems(item.Owner, uuids);
}
}
}
@ -2404,7 +2419,9 @@ namespace OpenSim.Region.Framework.Scenes
}
part.ParentGroup.DetachToGround();
InventoryService.DeleteItem(new InventoryItemBase(inventoryID));
List<UUID> uuids = new List<UUID>();
uuids.Add(inventoryID);
InventoryService.DeleteItems(remoteClient.AgentId, uuids);
remoteClient.SendRemoveInventoryItem(inventoryID);
}
SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero);

View File

@ -560,7 +560,7 @@ namespace OpenSim.Region.Framework.Scenes
public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, UUID folderID)
{
InventoryFolderBase folder = new InventoryFolderBase(folderID);
InventoryFolderBase folder = new InventoryFolderBase(folderID, remoteClient.AgentId);
if (InventoryService.PurgeFolder(folder))
m_log.DebugFormat("[AGENT INVENTORY]: folder {0} purged successfully", folderID);

View File

@ -105,8 +105,8 @@ namespace OpenSim.Server.Handlers.Inventory
"POST", "/PurgeFolder/", m_InventoryService.PurgeFolder, CheckAuthSession));
m_httpServer.AddStreamHandler(
new RestDeserialiseSecureHandler<InventoryItemBase, bool>(
"POST", "/DeleteItem/", m_InventoryService.DeleteItem, CheckAuthSession));
new RestDeserialiseSecureHandler<List<Guid>, bool>(
"POST", "/DeleteItem/", DeleteItems, CheckAuthSession));
m_httpServer.AddStreamHandler(
new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>(
@ -247,6 +247,15 @@ namespace OpenSim.Server.Handlers.Inventory
return m_InventoryService.GetAssetPermissions(item.Owner, item.AssetID);
}
public bool DeleteItems(List<Guid> items)
{
List<UUID> uuids = new List<UUID>();
foreach (Guid g in items)
uuids.Add(new UUID(g));
// oops we lost the user info here. Bad bad handlers
return m_InventoryService.DeleteItems(UUID.Zero, uuids);
}
#endregion
/// <summary>

View File

@ -253,7 +253,7 @@ namespace OpenSim.Services.Connectors.Inventory
return false;
}
public bool DeleteItem(string id, InventoryItemBase item, UUID sessionID)
public bool DeleteItems(string id, List<UUID> itemIDs, UUID sessionID)
{
string url = string.Empty;
string userID = string.Empty;
@ -261,7 +261,7 @@ namespace OpenSim.Services.Connectors.Inventory
if (StringToUrlAndUserID(id, out url, out userID))
{
ISessionAuthInventoryService connector = GetConnector(url);
return connector.UpdateItem(userID, item, sessionID);
return connector.DeleteItems(userID, itemIDs, sessionID);
}
return false;
}

View File

@ -121,7 +121,7 @@ namespace OpenSim.Services.Connectors
/// </summary>
/// <param name="item"></param>
/// <returns>true if the item was successfully deleted</returns>
bool DeleteItem(string userID, InventoryItemBase item, UUID session_id);
bool DeleteItems(string userID, List<UUID> itemIDs, UUID session_id);
InventoryItemBase QueryItem(string userID, InventoryItemBase item, UUID session_id);

View File

@ -383,12 +383,15 @@ namespace OpenSim.Services.Connectors
return false;
}
public bool DeleteItem(string userID, InventoryItemBase item, UUID sessionID)
public bool DeleteItems(string userID, List<UUID> items, UUID sessionID)
{
try
{
return SynchronousRestSessionObjectPoster<InventoryItemBase, bool>.BeginPostObject(
"POST", m_ServerURI + "/DeleteItem/", item, sessionID.ToString(), item.Owner.ToString());
List<Guid> guids = new List<Guid>();
foreach (UUID u in items)
guids.Add(u.Guid);
return SynchronousRestSessionObjectPoster<List<Guid>, bool>.BeginPostObject(
"POST", m_ServerURI + "/DeleteItem/", guids, sessionID.ToString(), userID);
}
catch (Exception e)
{

View File

@ -151,7 +151,7 @@ namespace OpenSim.Services.Connectors
return false;
}
public bool DeleteItem(InventoryItemBase item)
public bool DeleteItems(UUID owner, List<UUID> itemIDs)
{
return false;
}

View File

@ -147,7 +147,8 @@ namespace OpenSim.Services.Interfaces
/// </summary>
/// <param name="item"></param>
/// <returns>true if the item was successfully deleted</returns>
bool DeleteItem(InventoryItemBase item);
//bool DeleteItem(InventoryItemBase item);
bool DeleteItems(UUID userID, List<UUID> itemIDs);
/// <summary>
/// Get an item, given by its UUID

View File

@ -387,12 +387,14 @@ namespace OpenSim.Services.InventoryService
}
// See IInventoryServices
public virtual bool DeleteItem(InventoryItemBase item)
public virtual bool DeleteItems(UUID owner, List<UUID> itemIDs)
{
m_log.InfoFormat(
"[INVENTORY SERVICE]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder);
"[INVENTORY SERVICE]: Deleting {0} items from user {1}", itemIDs.Count, owner);
m_Database.deleteInventoryItem(item.ID);
// uhh.....
foreach (UUID uuid in itemIDs)
m_Database.deleteInventoryItem(uuid);
// FIXME: Should return false on failure
return true;
@ -439,10 +441,12 @@ namespace OpenSim.Services.InventoryService
List<InventoryItemBase> items = GetFolderItems(folder.Owner, folder.ID);
List<UUID> uuids = new List<UUID>();
foreach (InventoryItemBase item in items)
{
DeleteItem(item);
uuids.Add(item.ID);
}
DeleteItems(folder.Owner, uuids);
// FIXME: Should return false on failure
return true;

View File

@ -143,7 +143,7 @@ namespace OpenSim.Tests.Common.Mock
return false;
}
public bool DeleteItem(InventoryItemBase item)
public bool DeleteItems(UUID ownerID, List<UUID> itemIDs)
{
return false;
}