From 4db839c3b84bed8a775074beb1ae0b526bc05e81 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Wed, 23 Apr 2008 17:04:15 +0000
Subject: * Implement proper emptying of trashcan on standalone * On
standalone, folders (and their items) should now be persistently deleted on
trash emptying, as well as immediate child items * An implementation for grid
mode will follow.
---
OpenSim/Data/MySQL/MySQLInventoryData.cs | 2 +-
.../Communications/Cache/InventoryFolderImpl.cs | 8 ++--
.../Cache/UserProfileCacheService.cs | 29 +++++++++++---
.../Framework/Communications/IInventoryServices.cs | 12 ++++++
.../Communications/InventoryServiceBase.cs | 45 +++++++++++++++++++++-
OpenSim/Framework/IInventoryData.cs | 2 +-
OpenSim/Framework/InventoryItemBase.cs | 2 -
.../Grid/InventoryServer/GridInventoryService.cs | 10 +++++
.../Communications/Local/LocalInventoryService.cs | 10 +++++
.../Communications/OGS1/OGS1InventoryService.cs | 10 +++++
10 files changed, 115 insertions(+), 15 deletions(-)
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs
index 3aed301..dbcb9bd 100644
--- a/OpenSim/Data/MySQL/MySQLInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs
@@ -637,7 +637,7 @@ namespace OpenSim.Data.MySQL
}
///
- /// Delete an inventory folder
+ /// Deletes an inventory folder
///
/// Id of folder to delete
public void deleteInventoryFolder(LLUUID folderID)
diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
index daf9ab5..7812499 100644
--- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
+++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
@@ -79,14 +79,12 @@ namespace OpenSim.Framework.Communications.Cache
///
/// Delete all the folders and items in this folder.
- ///
- /// TODO: This method is not used yet, but will be shortly
///
- public void DeleteAllContents()
+ public void Purge()
{
foreach (InventoryFolderImpl folder in SubFolders.Values)
{
- folder.DeleteAllContents();
+ folder.Purge();
}
SubFolders.Clear();
@@ -206,7 +204,7 @@ namespace OpenSim.Framework.Communications.Cache
}
///
- /// Return the list of folders in this folder
+ /// Return the list of immediate child folders in this folder.
///
public List RequestListOfFolders()
{
diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
index e3f6815..61ec483 100644
--- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
+++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
@@ -496,6 +496,11 @@ namespace OpenSim.Framework.Communications.Cache
return new List();
}
+ ///
+ /// This should delete all the items and folders in the given directory.
+ ///
+ ///
+ ///
public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, LLUUID folderID)
{
// m_log.InfoFormat("[AGENT INVENTORY]: Purging folder {0} for {1} uuid {2}",
@@ -506,14 +511,28 @@ namespace OpenSim.Framework.Communications.Cache
{
if (userProfile.HasInventory)
{
- InventoryFolderImpl subFolder = userProfile.RootFolder.HasSubFolder(folderID);
- if (subFolder != null)
- {
- List items = subFolder.RequestListOfItems();
+ InventoryFolderImpl purgedFolder = userProfile.RootFolder.HasSubFolder(folderID);
+ if (purgedFolder != null)
+ {
+ // XXX Nasty - have to create a new object to hold details we already have
+ InventoryFolderBase purgedBaseFolder = new InventoryFolderBase();
+ purgedBaseFolder.Owner = purgedFolder.Owner;
+ purgedBaseFolder.ID = purgedFolder.ID;
+ purgedBaseFolder.Name = purgedFolder.Name;
+ purgedBaseFolder.ParentID = purgedFolder.ParentID;
+ purgedBaseFolder.Type = purgedFolder.Type;
+ purgedBaseFolder.Version = purgedFolder.Version;
+
+ m_commsManager.InventoryService.PurgeInventoryFolder(remoteClient.AgentId, purgedBaseFolder);
+
+ // XXX Remains temporarily so that we still delete items in the grid case.
+ List items = purgedFolder.RequestListOfItems();
foreach (InventoryItemBase item in items)
{
userProfile.DeleteItem(remoteClient.AgentId, item);
- }
+ }
+
+ purgedFolder.Purge();
}
}
else
diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs
index 90bda01..5690f89 100644
--- a/OpenSim/Framework/Communications/IInventoryServices.cs
+++ b/OpenSim/Framework/Communications/IInventoryServices.cs
@@ -56,9 +56,21 @@ namespace OpenSim.Framework.Communications
///
void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder);
+ ///
+ /// Move an inventory folder to a new location
+ ///
+ ///
+ /// A folder containing the details of the new location
void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder);
///
+ /// Purge an inventory folder of all its items and subfolders.
+ ///
+ ///
+ ///
+ void PurgeInventoryFolder(LLUUID userID, InventoryFolderBase folder);
+
+ ///
/// Add a new item to the given user's inventory
///
///
diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs
index f614e7d..769c530 100644
--- a/OpenSim/Framework/Communications/InventoryServiceBase.cs
+++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs
@@ -50,7 +50,7 @@ namespace OpenSim.Framework.Communications
{
if (!String.IsNullOrEmpty(FileName))
{
- m_log.Info("[AGENTINVENTORY]: Inventory storage: Attempting to load " + FileName);
+ m_log.Info("[AGENT INVENTORY]: Inventory storage: Attempting to load " + FileName);
Assembly pluginAssembly = Assembly.LoadFrom(FileName);
foreach (Type pluginType in pluginAssembly.GetTypes())
@@ -161,9 +161,19 @@ namespace OpenSim.Framework.Communications
// See IInventoryServices
public abstract void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback);
+ // See IInventoryServices
public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder);
+
+ // See IInventoryServices
public abstract void MoveExistingInventoryFolder(InventoryFolderBase folder);
+
+ // See IInventoryServices
+ public abstract void PurgeInventoryFolder(LLUUID userID, InventoryFolderBase folder);
+
+ // See IInventoryServices
public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item);
+
+ // See IInventoryServices
public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item);
#endregion
@@ -228,6 +238,36 @@ namespace OpenSim.Framework.Communications
}
}
+ ///
+ /// Purge a folder of all items items and subfolders.
+ ///
+ /// FIXME: Really nasty in a sense, because we have to query the database to get information we may
+ /// already know... Needs heavy refactoring.
+ ///
+ ///
+ protected void PurgeFolder(InventoryFolderBase folder)
+ {
+ List subFolders = RequestSubFolders(folder.ID);
+
+ foreach (InventoryFolderBase subFolder in subFolders)
+ {
+// m_log.DebugFormat("[AGENT INVENTORY]: Deleting folder {0} {1}", subFolder.Name, subFolder.ID);
+
+ foreach (KeyValuePair plugin in m_plugins)
+ {
+ plugin.Value.deleteInventoryFolder(subFolder.ID);
+ }
+ }
+
+ // XXX Temporarily don't delete the items since UserProfileCacheService is still doing this
+// List items = RequestFolderItems(folder.ID);
+//
+// foreach (InventoryItemBase item : items)
+// {
+// DeleteItem(item);
+// }
+ }
+
private void AddNewInventorySet(UsersInventory inventory)
{
foreach (InventoryFolderBase folder in inventory.Folders.Values)
@@ -236,6 +276,9 @@ namespace OpenSim.Framework.Communications
}
}
+ ///
+ /// Used to create a new user inventory.
+ ///
private class UsersInventory
{
public Dictionary Folders = new Dictionary();
diff --git a/OpenSim/Framework/IInventoryData.cs b/OpenSim/Framework/IInventoryData.cs
index 6a500f8..d72231d 100644
--- a/OpenSim/Framework/IInventoryData.cs
+++ b/OpenSim/Framework/IInventoryData.cs
@@ -144,7 +144,7 @@ namespace OpenSim.Framework
void moveInventoryFolder(InventoryFolderBase folder);
///
- /// Deletes a folder based on its ID with folder
+ /// Deletes a folder. Thie will delete both the folder itself and its contents (items and descendent folders)
///
/// The id of the folder
void deleteInventoryFolder(LLUUID folder);
diff --git a/OpenSim/Framework/InventoryItemBase.cs b/OpenSim/Framework/InventoryItemBase.cs
index 8c8d858..6ed2961 100644
--- a/OpenSim/Framework/InventoryItemBase.cs
+++ b/OpenSim/Framework/InventoryItemBase.cs
@@ -108,8 +108,6 @@ namespace OpenSim.Framework
}
}
-
-
public int InvType {
get {
return _invType;
diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs
index fe892ca..016ecff 100644
--- a/OpenSim/Grid/InventoryServer/GridInventoryService.cs
+++ b/OpenSim/Grid/InventoryServer/GridInventoryService.cs
@@ -220,6 +220,16 @@ namespace OpenSim.Grid.InventoryServer
MoveExistingInventoryFolder(folder);
return true;
}
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override void PurgeInventoryFolder(LLUUID userID, InventoryFolderBase folder)
+ {
+ // XXX No implementation yet (temporarily)!
+ }
public bool AddInventoryItem(InventoryItemBase item)
{
diff --git a/OpenSim/Region/Communications/Local/LocalInventoryService.cs b/OpenSim/Region/Communications/Local/LocalInventoryService.cs
index a567eeb..175829b 100644
--- a/OpenSim/Region/Communications/Local/LocalInventoryService.cs
+++ b/OpenSim/Region/Communications/Local/LocalInventoryService.cs
@@ -100,6 +100,16 @@ namespace OpenSim.Region.Communications.Local
DeleteItem(item);
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override void PurgeInventoryFolder(LLUUID userID, InventoryFolderBase folder)
+ {
+ PurgeFolder(folder);
+ }
+
public override bool HasInventoryForUser(LLUUID userID)
{
InventoryFolderBase root = RequestRootFolder(userID);
diff --git a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs
index e0167a7..8c27cb1 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs
@@ -175,6 +175,16 @@ namespace OpenSim.Region.Communications.OGS1
e.Source, e.Message);
}
}
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public void PurgeInventoryFolder(LLUUID userID, InventoryFolderBase folder)
+ {
+ // XXX No implementation yet (temporarily)!
+ }
public void AddNewInventoryItem(LLUUID userID, InventoryItemBase item)
{
--
cgit v1.1