From 5bc3bbbcf3e7df23db3e3e0410266ba72a1a1e14 Mon Sep 17 00:00:00 2001 From: AliciaRaven Date: Sat, 6 Sep 2014 20:23:40 +0100 Subject: [PATCH] Add an event callback for loading IAR files. The callback for creating them already existed but not for loading. This is of interest for use by region modules. Also includes reporting numbers of items saved and items filtered to the completed log printout. --- .../Archiver/InventoryArchiveReadRequest.cs | 32 ++++++- .../Archiver/InventoryArchiveWriteRequest.cs | 24 +++++- .../Archiver/InventoryArchiverModule.cs | 86 ++++++++++++++----- .../Tests/InventoryArchiveLoadPathTests.cs | 22 ++--- .../Tests/InventoryArchiveLoadTests.cs | 8 +- .../Tests/InventoryArchiveSaveTests.cs | 4 +- .../Tests/InventoryArchiveTestCase.cs | 2 +- .../Framework/Library/LibraryModule.cs | 4 +- .../Interfaces/IInventoryArchiverModule.cs | 27 +++++- 9 files changed, 159 insertions(+), 50 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 9963521a4f..2730b3f98a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -61,6 +61,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver private UserAccount m_userInfo; private string m_invPath; + + /// + /// ID of this request + /// + protected UUID m_id; /// /// Do we want to merge this load with existing inventory? @@ -71,6 +76,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver protected IAssetService m_AssetService; protected IUserAccountService m_UserAccountService; + private InventoryArchiverModule m_module; + /// /// The stream from which the inventory archive will be loaded. /// @@ -117,9 +124,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver protected Dictionary m_creatorIdForAssetId = new Dictionary(); public InventoryArchiveReadRequest( - IInventoryService inv, IAssetService assets, IUserAccountService uacc, UserAccount userInfo, string invPath, string loadPath, bool merge) + UUID id, IInventoryService inv, InventoryArchiverModule module, IAssetService assets, IUserAccountService uacc, UserAccount userInfo, string invPath, string loadPath, bool merge) : this( + id, inv, + module, assets, uacc, userInfo, @@ -130,8 +139,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } public InventoryArchiveReadRequest( - IInventoryService inv, IAssetService assets, IUserAccountService uacc, UserAccount userInfo, string invPath, Stream loadStream, bool merge) + UUID id, IInventoryService inv, InventoryArchiverModule module, IAssetService assets, IUserAccountService uacc, UserAccount userInfo, string invPath, Stream loadStream, bool merge) { + m_id = id; m_InventoryService = inv; m_AssetService = assets; m_UserAccountService = uacc; @@ -139,6 +149,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_userInfo = userInfo; m_invPath = invPath; m_loadStream = loadStream; + m_module = module; // FIXME: Do not perform this check since older versions of OpenSim do save the control file after other things // (I thought they weren't). We will need to bump the version number and perform this check on all @@ -161,6 +172,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { try { + Exception reportedException = null; + string filePath = "ERROR"; List folderCandidates @@ -197,14 +210,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } archive.Close(); - + m_log.DebugFormat( "[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures", m_successfulAssetRestores, m_failedAssetRestores); - m_log.InfoFormat("[INVENTORY ARCHIVER]: Successfully loaded {0} items", m_successfulItemRestores); + + //Alicia: When this is called by LibraryModule or Tests, m_module will be null as event is not required + if(m_module != null) + m_module.TriggerInventoryArchiveLoaded(m_id, true, m_userInfo, m_invPath, m_loadStream, reportedException, m_successfulItemRestores); return m_loadedNodes; } + catch(Exception Ex) + { + // Trigger saved event with failed result and exception data + if (m_module != null) + m_module.TriggerInventoryArchiveLoaded(m_id, false, m_userInfo, m_invPath, m_loadStream, Ex, 0); + + return m_loadedNodes; + } finally { m_loadStream.Close(); diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 0605db5ae3..401a238674 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -61,6 +61,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// public string FilterContent { get; set; } + /// + /// Counter for inventory items saved to archive for passing to compltion event + /// + public int CountItems { get; set; } + + /// + /// Counter for inventory items skipped due to permission filter option for passing to compltion event + /// + public int CountFiltered { get; set; } + /// /// Used to select all inventory nodes in a folder but not the folder itself /// @@ -158,7 +168,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } m_module.TriggerInventoryArchiveSaved( - m_id, succeeded, m_userInfo, m_invPath, m_saveStream, reportedException); + m_id, succeeded, m_userInfo, m_invPath, m_saveStream, reportedException, CountItems, CountFiltered); } protected void SaveInvItem(InventoryItemBase inventoryItem, string path, Dictionary options, IUserAccountService userAccountService) @@ -174,6 +184,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver "[INVENTORY ARCHIVER]: Skipping inventory item {0} {1} at {2}", inventoryItem.Name, inventoryItem.ID, path); } + + CountFiltered++; + return; } } @@ -184,6 +197,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_log.InfoFormat( "[INVENTORY ARCHIVER]: Insufficient permissions, skipping inventory item {0} {1} at {2}", inventoryItem.Name, inventoryItem.ID, path); + + // Count Items Excluded + CountFiltered++; + return; } @@ -202,6 +219,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver AssetType itemAssetType = (AssetType)inventoryItem.AssetType; + // Count inventory items (different to asset count) + CountItems++; + // Don't chase down link asset items as they actually point to their target item IDs rather than an asset if (SaveAssets && itemAssetType != AssetType.Link && itemAssetType != AssetType.LinkFolder) m_assetGatherer.GatherAssetUuids(inventoryItem.AssetID, (sbyte)inventoryItem.AssetType, m_assetUuids); @@ -363,7 +383,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // We couldn't find the path indicated string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath); Exception e = new InventoryArchiverException(errorMessage); - m_module.TriggerInventoryArchiveSaved(m_id, false, m_userInfo, m_invPath, m_saveStream, e); + m_module.TriggerInventoryArchiveSaved(m_id, false, m_userInfo, m_invPath, m_saveStream, e, 0, 0); throw e; } diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 0e4d79c47f..b85bbea463 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -57,6 +57,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // public bool DisablePresenceChecks { get; set; } public event InventoryArchiveSaved OnInventoryArchiveSaved; + public event InventoryArchiveLoaded OnInventoryArchiveLoaded; /// /// The file to load and save inventory if no filename has been specified @@ -64,9 +65,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver protected const string DEFAULT_INV_BACKUP_FILENAME = "user-inventory.iar"; /// - /// Pending save completions initiated from the console + /// Pending save and load completions initiated from the console /// - protected List m_pendingConsoleSaves = new List(); + protected List m_pendingConsoleTasks = new List(); /// /// All scenes that this module knows about @@ -111,6 +112,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { scene.RegisterModuleInterface(this); OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted; + OnInventoryArchiveLoaded += LoadInvConsoleCommandCompleted; scene.AddCommand( "Archiving", this, "load iar", @@ -176,11 +178,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// protected internal void TriggerInventoryArchiveSaved( UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, - Exception reportedException) + Exception reportedException, int SaveCount, int FilterCount) { InventoryArchiveSaved handlerInventoryArchiveSaved = OnInventoryArchiveSaved; if (handlerInventoryArchiveSaved != null) - handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException); + handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException, SaveCount , FilterCount); + } + + /// + /// Trigger the inventory archive loaded event. + /// + protected internal void TriggerInventoryArchiveLoaded( + UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream loadStream, + Exception reportedException, int LoadCount) + { + InventoryArchiveLoaded handlerInventoryArchiveLoaded = OnInventoryArchiveLoaded; + if (handlerInventoryArchiveLoaded != null) + handlerInventoryArchiveLoaded(id, succeeded, userInfo, invPath, loadStream, reportedException, LoadCount); } public bool ArchiveInventory( @@ -272,13 +286,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver return false; } - public bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, Stream loadStream) + public bool DearchiveInventory(UUID id, string firstName, string lastName, string invPath, string pass, Stream loadStream) { - return DearchiveInventory(firstName, lastName, invPath, pass, loadStream, new Dictionary()); + return DearchiveInventory(id, firstName, lastName, invPath, pass, loadStream, new Dictionary()); } public bool DearchiveInventory( - string firstName, string lastName, string invPath, string pass, Stream loadStream, + UUID id, string firstName, string lastName, string invPath, string pass, Stream loadStream, Dictionary options) { if (m_scenes.Count > 0) @@ -294,7 +308,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver try { - request = new InventoryArchiveReadRequest(m_aScene.InventoryService, m_aScene.AssetService, m_aScene.UserAccountService, userInfo, invPath, loadStream, merge); + request = new InventoryArchiveReadRequest(id, m_aScene.InventoryService, this, m_aScene.AssetService, m_aScene.UserAccountService, userInfo, invPath, loadStream, merge); } catch (EntryPointNotFoundException e) { @@ -326,7 +340,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } public bool DearchiveInventory( - string firstName, string lastName, string invPath, string pass, string loadPath, + UUID id, string firstName, string lastName, string invPath, string pass, string loadPath, Dictionary options) { if (m_scenes.Count > 0) @@ -342,7 +356,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver try { - request = new InventoryArchiveReadRequest(m_aScene.InventoryService, m_aScene.AssetService, m_aScene.UserAccountService, userInfo, invPath, loadPath, merge); + request = new InventoryArchiveReadRequest(id, m_aScene.InventoryService, this, m_aScene.AssetService, m_aScene.UserAccountService, userInfo, invPath, loadPath, merge); } catch (EntryPointNotFoundException e) { @@ -378,6 +392,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { try { + UUID id = UUID.Random(); + Dictionary options = new Dictionary(); OptionSet optionSet = new OptionSet().Add("m|merge", delegate (string v) { options["merge"] = v != null; }); @@ -400,10 +416,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", loadPath, invPath, firstName, lastName); - if (DearchiveInventory(firstName, lastName, invPath, pass, loadPath, options)) - m_log.InfoFormat( - "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", - loadPath, firstName, lastName); + lock (m_pendingConsoleTasks) + m_pendingConsoleTasks.Add(id); + + DearchiveInventory(id, firstName, lastName, invPath, pass, loadPath, options); } catch (InventoryArchiverException e) { @@ -465,8 +481,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}", savePath, invPath, firstName, lastName); - lock (m_pendingConsoleSaves) - m_pendingConsoleSaves.Add(id); + lock (m_pendingConsoleTasks) + m_pendingConsoleTasks.Add(id); ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, options); } @@ -478,19 +494,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver private void SaveInvConsoleCommandCompleted( UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, - Exception reportedException) + Exception reportedException, int SaveCount, int FilterCount) { - lock (m_pendingConsoleSaves) + lock (m_pendingConsoleTasks) { - if (m_pendingConsoleSaves.Contains(id)) - m_pendingConsoleSaves.Remove(id); + if (m_pendingConsoleTasks.Contains(id)) + m_pendingConsoleTasks.Remove(id); else return; } if (succeeded) { - m_log.InfoFormat("[INVENTORY ARCHIVER]: Saved archive for {0} {1}", userInfo.FirstName, userInfo.LastName); + // Report success and include item count and filter count (Skipped items due to --perm or --exclude switches) + if(FilterCount == 0) + m_log.InfoFormat("[INVENTORY ARCHIVER]: Saved archive with {0} items for {1} {2}", SaveCount, userInfo.FirstName, userInfo.LastName); + else + m_log.InfoFormat("[INVENTORY ARCHIVER]: Saved archive with {0} items for {1} {2}. Skipped {3} items due to exclude and/or perm switches", SaveCount, userInfo.FirstName, userInfo.LastName, FilterCount); } else { @@ -500,6 +520,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } } + private void LoadInvConsoleCommandCompleted( + UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream loadStream, + Exception reportedException, int LoadCount) + { + lock (m_pendingConsoleTasks) + { + if (m_pendingConsoleTasks.Contains(id)) + m_pendingConsoleTasks.Remove(id); + else + return; + } + + if (succeeded) + { + m_log.InfoFormat("[INVENTORY ARCHIVER]: Loaded {0} items from archive {1} for {2} {3}", LoadCount, invPath, userInfo.FirstName, userInfo.LastName); + } + else + { + m_log.ErrorFormat( + "[INVENTORY ARCHIVER]: Archive load for {0} {1} failed - {2}", + userInfo.FirstName, userInfo.LastName, reportedException.Message); + } + } + /// /// Get user information for the given name. /// diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveLoadPathTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveLoadPathTests.cs index dabece3abc..eb2515e3e6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveLoadPathTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveLoadPathTests.cs @@ -69,8 +69,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "meowfood"); UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); - - archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream); + + archiverModule.DearchiveInventory(UUID.Random(), m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream); InventoryItemBase foundItem1 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, m_item1Name); @@ -79,7 +79,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests // Now try loading to a root child folder UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xA", false); MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray()); - archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xA", "meowfood", archiveReadStream); + archiverModule.DearchiveInventory(UUID.Random(), m_uaMT.FirstName, m_uaMT.LastName, "xA", "meowfood", archiveReadStream); InventoryItemBase foundItem2 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, "xA/" + m_item1Name); @@ -88,7 +88,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests // Now try loading to a more deeply nested folder UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC", false); archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); - archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xB/xC", "meowfood", archiveReadStream); + archiverModule.DearchiveInventory(UUID.Random(), m_uaMT.FirstName, m_uaMT.LastName, "xB/xC", "meowfood", archiveReadStream); InventoryItemBase foundItem3 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC/" + m_item1Name); @@ -110,7 +110,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests SceneHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "password"); - archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/Objects", "password", m_iarStream); + archiverModule.DearchiveInventory(UUID.Random(), m_uaMT.FirstName, m_uaMT.LastName, "/Objects", "password", m_iarStream); InventoryItemBase foundItem1 = InventoryArchiveUtils.FindItemByPath( @@ -185,8 +185,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests // LOAD ITEM MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); - - archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream); + + archiverModule.DearchiveInventory(UUID.Random(), userFirstName, userLastName, "Scripts", userPassword, archiveReadStream); InventoryItemBase foundItem1 = InventoryArchiveUtils.FindItemByPath( @@ -229,7 +229,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests { // Test replication of path1 - new InventoryArchiveReadRequest(scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null, false) + new InventoryArchiveReadRequest(UUID.Random(), scene.InventoryService, null, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null, false) .ReplicateArchivePathToUserInventory( iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID), foldersCreated, nodesLoaded); @@ -246,7 +246,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests { // Test replication of path2 - new InventoryArchiveReadRequest(scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null, false) + new InventoryArchiveReadRequest(UUID.Random(), scene.InventoryService, null, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null, false) .ReplicateArchivePathToUserInventory( iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID), foldersCreated, nodesLoaded); @@ -292,7 +292,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); - new InventoryArchiveReadRequest(scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null, false) + new InventoryArchiveReadRequest(UUID.Random(), scene.InventoryService, null, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null, false) .ReplicateArchivePathToUserInventory( itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), new Dictionary(), new HashSet()); @@ -343,7 +343,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); - new InventoryArchiveReadRequest(scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, folder1ExistingName, (Stream)null, true) + new InventoryArchiveReadRequest(UUID.Random(), scene.InventoryService, null, scene.AssetService, scene.UserAccountService, ua1, folder1ExistingName, (Stream)null, true) .ReplicateArchivePathToUserInventory( itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), new Dictionary(), new HashSet()); diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveLoadTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveLoadTests.cs index 1b521fcb50..3f16a16bdb 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveLoadTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveLoadTests.cs @@ -72,7 +72,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests // TestHelpers.EnableLogging(); UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "password"); - m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "password", m_iarStream); + m_archiverModule.DearchiveInventory(UUID.Random(), m_uaLL1.FirstName, m_uaLL1.LastName, "/", "password", m_iarStream); InventoryItemBase coaItem = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_coaItemName); @@ -106,8 +106,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests // log4net.Config.XmlConfigurator.Configure(); UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "meowfood"); - - m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "meowfood", m_iarStream); + + m_archiverModule.DearchiveInventory(UUID.Random(), m_uaLL1.FirstName, m_uaLL1.LastName, "/", "meowfood", m_iarStream); InventoryItemBase foundItem1 = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_item1Name); @@ -171,7 +171,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests // log4net.Config.XmlConfigurator.Configure(); UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "password"); - m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "password", m_iarStream); + m_archiverModule.DearchiveInventory(UUID.Random(), m_uaMT.FirstName, m_uaMT.LastName, "/", "password", m_iarStream); InventoryItemBase foundItem1 = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name); diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveSaveTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveSaveTests.cs index 254aa114ec..4791a79576 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveSaveTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveSaveTests.cs @@ -85,8 +85,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests byte[] data = tar.ReadEntry(out filePath, out tarEntryType); Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH)); - InventoryArchiveReadRequest iarr - = new InventoryArchiveReadRequest(null, null, null, null, null, (Stream)null, false); + InventoryArchiveReadRequest iarr + = new InventoryArchiveReadRequest(UUID.Random(), null, null, null, null, null, null, (Stream)null, false); iarr.LoadControlFile(filePath, data); Assert.That(iarr.ControlFileLoaded, Is.True); diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs index cc746d5e60..e2d95dab10 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs @@ -170,7 +170,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests protected void SaveCompleted( UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, - Exception reportedException) + Exception reportedException, int SaveCount, int FilterCount) { mre.Set(); } diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs index d10c9b427a..4d4720d454 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs @@ -176,7 +176,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library m_log.InfoFormat("[LIBRARY MODULE]: Loading library archive {0} ({1})...", iarFileName, simpleName); simpleName = GetInventoryPathFromName(simpleName); - InventoryArchiveReadRequest archread = new InventoryArchiveReadRequest(m_MockScene.InventoryService, m_MockScene.AssetService, m_MockScene.UserAccountService, uinfo, simpleName, iarFileName, false); + InventoryArchiveReadRequest archread = new InventoryArchiveReadRequest(UUID.Random(), m_MockScene.InventoryService, null, m_MockScene.AssetService, m_MockScene.UserAccountService, uinfo, simpleName, iarFileName, false); try { HashSet nodes = archread.Execute(); @@ -185,7 +185,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library // didn't find the subfolder with the given name; place it on the top m_log.InfoFormat("[LIBRARY MODULE]: Didn't find {0} in library. Placing archive on the top level", simpleName); archread.Close(); - archread = new InventoryArchiveReadRequest(m_MockScene.InventoryService, m_MockScene.AssetService, m_MockScene.UserAccountService, uinfo, "/", iarFileName, false); + archread = new InventoryArchiveReadRequest(UUID.Random(), m_MockScene.InventoryService, null, m_MockScene.AssetService, m_MockScene.UserAccountService, uinfo, "/", iarFileName, false); archread.Execute(); } diff --git a/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs b/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs index 54251a4262..0795589e13 100644 --- a/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs @@ -42,8 +42,24 @@ namespace OpenSim.Region.Framework.Interfaces /// The inventory path saved /// The stream to which the archive was saved /// Contains the exception generated if the save did not succeed + /// Number of inventory items saved to archive + /// Number of inventory items skipped due to perm filter option public delegate void InventoryArchiveSaved( - UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, Exception reportedException); + UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, Exception reportedException, int SaveCount, int FilterCount); + + /// + /// Used for the OnInventoryArchiveLoaded event. + /// + /// Request id + /// true if the load succeeded, false otherwise + /// The user for whom the load was conducted + /// The inventory path loaded + /// The stream from which the archive was loaded + /// Contains the exception generated if the load did not succeed + /// Number of inventory items loaded from archive + public delegate void InventoryArchiveLoaded( + UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream loadStream, Exception reportedException, int LoadCount); + public interface IInventoryArchiverModule { @@ -52,6 +68,11 @@ namespace OpenSim.Region.Framework.Interfaces /// event InventoryArchiveSaved OnInventoryArchiveSaved; + /// + /// Fired when an archive inventory load has been completed. + /// + event InventoryArchiveLoaded OnInventoryArchiveLoaded; + /// /// Dearchive a user's inventory folder from the given stream /// @@ -60,7 +81,7 @@ namespace OpenSim.Region.Framework.Interfaces /// The inventory path in which to place the loaded folders and items /// The stream from which the inventory archive will be loaded /// true if the first stage of the operation succeeded, false otherwise - bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, Stream loadStream); + bool DearchiveInventory(UUID id, string firstName, string lastName, string invPath, string pass, Stream loadStream); /// /// Dearchive a user's inventory folder from the given stream @@ -73,7 +94,7 @@ namespace OpenSim.Region.Framework.Interfaces /// the loaded IAR with existing folders where possible. /// true if the first stage of the operation succeeded, false otherwise bool DearchiveInventory( - string firstName, string lastName, string invPath, string pass, Stream loadStream, + UUID id, string firstName, string lastName, string invPath, string pass, Stream loadStream, Dictionary options); ///