From ad23774433b55e0cfbfc50208b247f0c3f41e8ea Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 23 Apr 2012 18:36:36 +0300 Subject: Allow deleting folders even if they're not in the Trash The functions DeleteFolders() and PurgeFolder() still work as before, i.e. they only allow deleting folders that are in the Trash. However, the functions DeleteFoldersEx() and PurgeFolderEx() can now be used to delete any folder. --- .../Services/InventoryService/XInventoryService.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'OpenSim/Services/InventoryService/XInventoryService.cs') diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index 0e7a358..37a6a42 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs @@ -364,6 +364,11 @@ namespace OpenSim.Services.InventoryService // public virtual bool DeleteFolders(UUID principalID, List folderIDs) { + return DeleteFoldersEx(principalID, folderIDs, true); + } + + public bool DeleteFoldersEx(UUID principalID, List folderIDs, bool onlyIfTrash) + { if (!m_AllowDelete) return false; @@ -371,11 +376,12 @@ namespace OpenSim.Services.InventoryService // foreach (UUID id in folderIDs) { - if (!ParentIsTrash(id)) + if (onlyIfTrash && !ParentIsTrash(id)) continue; + //m_log.InfoFormat("[XINVENTORY SERVICE]: Delete folder {0}", id); InventoryFolderBase f = new InventoryFolderBase(); f.ID = id; - PurgeFolder(f); + PurgeFolderEx(f, onlyIfTrash); m_Database.DeleteFolders("folderID", id.ToString()); } @@ -384,10 +390,15 @@ namespace OpenSim.Services.InventoryService public virtual bool PurgeFolder(InventoryFolderBase folder) { + return PurgeFolderEx(folder, true); + } + + private bool PurgeFolderEx(InventoryFolderBase folder, bool onlyIfTrash) + { if (!m_AllowDelete) return false; - if (!ParentIsTrash(folder.ID)) + if (onlyIfTrash && !ParentIsTrash(folder.ID)) return false; XInventoryFolder[] subFolders = m_Database.GetFolders( @@ -396,7 +407,7 @@ namespace OpenSim.Services.InventoryService foreach (XInventoryFolder x in subFolders) { - PurgeFolder(ConvertToOpenSim(x)); + PurgeFolderEx(ConvertToOpenSim(x), onlyIfTrash); m_Database.DeleteFolders("folderID", x.folderID.ToString()); } -- cgit v1.1 From e83bc049dffba51a4d739d150cbd82a68453a0c6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 4 May 2012 20:37:21 +0100 Subject: refactor: Rename new DeleteFoldersEx/PurgeFoldersEx methods to DeleteFolders/PurgeFolders overloads as previously discussed with Oren - I think this makes more sense on balance These overloads are not publicly available on core connectors or IInventoryService. --- OpenSim/Services/InventoryService/XInventoryService.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'OpenSim/Services/InventoryService/XInventoryService.cs') diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index 37a6a42..15156d0 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs @@ -52,6 +52,7 @@ namespace OpenSim.Services.InventoryService : this(config, "InventoryService") { } + public XInventoryService(IConfigSource config, string configName) : base(config) { if (configName != string.Empty) @@ -364,10 +365,10 @@ namespace OpenSim.Services.InventoryService // public virtual bool DeleteFolders(UUID principalID, List folderIDs) { - return DeleteFoldersEx(principalID, folderIDs, true); + return DeleteFolders(principalID, folderIDs, true); } - public bool DeleteFoldersEx(UUID principalID, List folderIDs, bool onlyIfTrash) + public virtual bool DeleteFolders(UUID principalID, List folderIDs, bool onlyIfTrash) { if (!m_AllowDelete) return false; @@ -381,7 +382,7 @@ namespace OpenSim.Services.InventoryService //m_log.InfoFormat("[XINVENTORY SERVICE]: Delete folder {0}", id); InventoryFolderBase f = new InventoryFolderBase(); f.ID = id; - PurgeFolderEx(f, onlyIfTrash); + PurgeFolder(f, onlyIfTrash); m_Database.DeleteFolders("folderID", id.ToString()); } @@ -390,10 +391,10 @@ namespace OpenSim.Services.InventoryService public virtual bool PurgeFolder(InventoryFolderBase folder) { - return PurgeFolderEx(folder, true); + return PurgeFolder(folder, true); } - private bool PurgeFolderEx(InventoryFolderBase folder, bool onlyIfTrash) + public virtual bool PurgeFolder(InventoryFolderBase folder, bool onlyIfTrash) { if (!m_AllowDelete) return false; @@ -407,7 +408,7 @@ namespace OpenSim.Services.InventoryService foreach (XInventoryFolder x in subFolders) { - PurgeFolderEx(ConvertToOpenSim(x), onlyIfTrash); + PurgeFolder(ConvertToOpenSim(x), onlyIfTrash); m_Database.DeleteFolders("folderID", x.folderID.ToString()); } -- cgit v1.1