From 910a5c842a0c6ecddc787486cdc804f477930ba7 Mon Sep 17 00:00:00 2001 From: Kevin Cozens Date: Fri, 17 Feb 2012 22:00:07 -0500 Subject: [PATCH] Track inventory folders to give more control over what is saved to IAR. --- .../Archiver/InventoryArchiveWriteRequest.cs | 39 +++++++++++++++---- .../Archiver/InventoryArchiverModule.cs | 2 +- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 3bda6b42a1..75c9a99930 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -144,11 +144,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_id, succeeded, m_userInfo, m_invPath, m_saveStream, reportedException); } - protected void SaveInvItem(InventoryItemBase inventoryItem, string path, Dictionary options, IUserAccountService userAccountService) + protected void SaveInvItem( + InventoryItemBase inventoryItem, string path, Dictionary options, + IUserAccountService userAccountService, string folderPath) { if (options.ContainsKey("exclude")) { - if (((List)options["exclude"]).Contains(inventoryItem.Name) || + //Full details of current item is folder path plus item name. + folderPath = CreateFolderPath(folderPath, inventoryItem.Name); + + if (((List)options["exclude"]).Contains(folderPath) || ((List)options["exclude"]).Contains(inventoryItem.ID.ToString())) { if (options.ContainsKey("verbose")) @@ -189,13 +194,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// If true, save this folder itself. If false, only saves contents /// /// + /// Path to previous (parent) folder protected void SaveInvFolder( InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself, - Dictionary options, IUserAccountService userAccountService) + Dictionary options, IUserAccountService userAccountService, string folderPath) { + //Current folder path is previous folder path plus current folder. + folderPath = CreateFolderPath(folderPath, inventoryFolder.Name); + if (options.ContainsKey("excludefolders")) { - if (((List)options["excludefolders"]).Contains(inventoryFolder.Name) || + if (((List)options["excludefolders"]).Contains(folderPath) || ((List)options["excludefolders"]).Contains(inventoryFolder.ID.ToString())) { if (options.ContainsKey("verbose")) @@ -224,12 +233,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver foreach (InventoryFolderBase childFolder in contents.Folders) { - SaveInvFolder(childFolder, path, true, options, userAccountService); + SaveInvFolder(childFolder, path, true, options, userAccountService, folderPath); } foreach (InventoryItemBase item in contents.Items) { - SaveInvItem(item, path, options, userAccountService); + SaveInvItem(item, path, options, userAccountService, folderPath); } } @@ -315,7 +324,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_invPath == String.Empty ? InventoryFolderImpl.PATH_DELIMITER : m_invPath); //recurse through all dirs getting dirs and files - SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !saveFolderContentsOnly, options, userAccountService); + SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !saveFolderContentsOnly, options, userAccountService, String.Empty); } else if (inventoryItem != null) { @@ -323,7 +332,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}", inventoryItem.Name, inventoryItem.ID, m_invPath); - SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH, options, userAccountService); + SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH, options, userAccountService, m_invPath); } // Don't put all this profile information into the archive right now. @@ -436,6 +445,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver id); } + /// + /// Create the path to the inventory folder about to be processed + /// + /// + /// + /// + public string CreateFolderPath(string folderPath, string subFolder) + { + if (folderPath != "") + folderPath += "/"; + + return folderPath + subFolder; + } + /// /// Create the control file for the archive /// diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 1cec52428b..4112884e91 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -132,7 +132,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver + "-e|--exclude= don't save the inventory item in archive" + Environment.NewLine + "-f|--excludefolder= don't save contents of the folder in archive" + Environment.NewLine + "-v|--verbose extra debug messages." + Environment.NewLine - + "--noassets stops assets being saved to the IAR." + + "--noassets stops assets being saved to the IAR." + Environment.NewLine + " is the filesystem path at which to save the IAR." + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME), HandleSaveInvConsoleCommand);