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.
parent
08675d44a7
commit
5bc3bbbcf3
|
@ -62,6 +62,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
private UserAccount m_userInfo;
|
private UserAccount m_userInfo;
|
||||||
private string m_invPath;
|
private string m_invPath;
|
||||||
|
|
||||||
|
/// <value>
|
||||||
|
/// ID of this request
|
||||||
|
/// </value>
|
||||||
|
protected UUID m_id;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Do we want to merge this load with existing inventory?
|
/// Do we want to merge this load with existing inventory?
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -71,6 +76,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
protected IAssetService m_AssetService;
|
protected IAssetService m_AssetService;
|
||||||
protected IUserAccountService m_UserAccountService;
|
protected IUserAccountService m_UserAccountService;
|
||||||
|
|
||||||
|
private InventoryArchiverModule m_module;
|
||||||
|
|
||||||
/// <value>
|
/// <value>
|
||||||
/// The stream from which the inventory archive will be loaded.
|
/// The stream from which the inventory archive will be loaded.
|
||||||
/// </value>
|
/// </value>
|
||||||
|
@ -117,9 +124,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
protected Dictionary<UUID, UUID> m_creatorIdForAssetId = new Dictionary<UUID, UUID>();
|
protected Dictionary<UUID, UUID> m_creatorIdForAssetId = new Dictionary<UUID, UUID>();
|
||||||
|
|
||||||
public InventoryArchiveReadRequest(
|
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(
|
: this(
|
||||||
|
id,
|
||||||
inv,
|
inv,
|
||||||
|
module,
|
||||||
assets,
|
assets,
|
||||||
uacc,
|
uacc,
|
||||||
userInfo,
|
userInfo,
|
||||||
|
@ -130,8 +139,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
}
|
}
|
||||||
|
|
||||||
public InventoryArchiveReadRequest(
|
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_InventoryService = inv;
|
||||||
m_AssetService = assets;
|
m_AssetService = assets;
|
||||||
m_UserAccountService = uacc;
|
m_UserAccountService = uacc;
|
||||||
|
@ -139,6 +149,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
m_userInfo = userInfo;
|
m_userInfo = userInfo;
|
||||||
m_invPath = invPath;
|
m_invPath = invPath;
|
||||||
m_loadStream = loadStream;
|
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
|
// 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
|
// (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
|
try
|
||||||
{
|
{
|
||||||
|
Exception reportedException = null;
|
||||||
|
|
||||||
string filePath = "ERROR";
|
string filePath = "ERROR";
|
||||||
|
|
||||||
List<InventoryFolderBase> folderCandidates
|
List<InventoryFolderBase> folderCandidates
|
||||||
|
@ -201,7 +214,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
m_log.DebugFormat(
|
m_log.DebugFormat(
|
||||||
"[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures",
|
"[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures",
|
||||||
m_successfulAssetRestores, m_failedAssetRestores);
|
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;
|
return m_loadedNodes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string FilterContent { get; set; }
|
public string FilterContent { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Counter for inventory items saved to archive for passing to compltion event
|
||||||
|
/// </summary>
|
||||||
|
public int CountItems { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Counter for inventory items skipped due to permission filter option for passing to compltion event
|
||||||
|
/// </summary>
|
||||||
|
public int CountFiltered { get; set; }
|
||||||
|
|
||||||
/// <value>
|
/// <value>
|
||||||
/// Used to select all inventory nodes in a folder but not the folder itself
|
/// Used to select all inventory nodes in a folder but not the folder itself
|
||||||
/// </value>
|
/// </value>
|
||||||
|
@ -158,7 +168,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
}
|
}
|
||||||
|
|
||||||
m_module.TriggerInventoryArchiveSaved(
|
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<string, object> options, IUserAccountService userAccountService)
|
protected void SaveInvItem(InventoryItemBase inventoryItem, string path, Dictionary<string, object> options, IUserAccountService userAccountService)
|
||||||
|
@ -174,6 +184,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
"[INVENTORY ARCHIVER]: Skipping inventory item {0} {1} at {2}",
|
"[INVENTORY ARCHIVER]: Skipping inventory item {0} {1} at {2}",
|
||||||
inventoryItem.Name, inventoryItem.ID, path);
|
inventoryItem.Name, inventoryItem.ID, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CountFiltered++;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,6 +197,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
m_log.InfoFormat(
|
m_log.InfoFormat(
|
||||||
"[INVENTORY ARCHIVER]: Insufficient permissions, skipping inventory item {0} {1} at {2}",
|
"[INVENTORY ARCHIVER]: Insufficient permissions, skipping inventory item {0} {1} at {2}",
|
||||||
inventoryItem.Name, inventoryItem.ID, path);
|
inventoryItem.Name, inventoryItem.ID, path);
|
||||||
|
|
||||||
|
// Count Items Excluded
|
||||||
|
CountFiltered++;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,6 +219,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
|
|
||||||
AssetType itemAssetType = (AssetType)inventoryItem.AssetType;
|
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
|
// 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)
|
if (SaveAssets && itemAssetType != AssetType.Link && itemAssetType != AssetType.LinkFolder)
|
||||||
m_assetGatherer.GatherAssetUuids(inventoryItem.AssetID, (sbyte)inventoryItem.AssetType, m_assetUuids);
|
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
|
// We couldn't find the path indicated
|
||||||
string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath);
|
string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath);
|
||||||
Exception e = new InventoryArchiverException(errorMessage);
|
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;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
// public bool DisablePresenceChecks { get; set; }
|
// public bool DisablePresenceChecks { get; set; }
|
||||||
|
|
||||||
public event InventoryArchiveSaved OnInventoryArchiveSaved;
|
public event InventoryArchiveSaved OnInventoryArchiveSaved;
|
||||||
|
public event InventoryArchiveLoaded OnInventoryArchiveLoaded;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The file to load and save inventory if no filename has been specified
|
/// 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";
|
protected const string DEFAULT_INV_BACKUP_FILENAME = "user-inventory.iar";
|
||||||
|
|
||||||
/// <value>
|
/// <value>
|
||||||
/// Pending save completions initiated from the console
|
/// Pending save and load completions initiated from the console
|
||||||
/// </value>
|
/// </value>
|
||||||
protected List<UUID> m_pendingConsoleSaves = new List<UUID>();
|
protected List<UUID> m_pendingConsoleTasks = new List<UUID>();
|
||||||
|
|
||||||
/// <value>
|
/// <value>
|
||||||
/// All scenes that this module knows about
|
/// All scenes that this module knows about
|
||||||
|
@ -111,6 +112,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
{
|
{
|
||||||
scene.RegisterModuleInterface<IInventoryArchiverModule>(this);
|
scene.RegisterModuleInterface<IInventoryArchiverModule>(this);
|
||||||
OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted;
|
OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted;
|
||||||
|
OnInventoryArchiveLoaded += LoadInvConsoleCommandCompleted;
|
||||||
|
|
||||||
scene.AddCommand(
|
scene.AddCommand(
|
||||||
"Archiving", this, "load iar",
|
"Archiving", this, "load iar",
|
||||||
|
@ -176,11 +178,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected internal void TriggerInventoryArchiveSaved(
|
protected internal void TriggerInventoryArchiveSaved(
|
||||||
UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
|
UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
|
||||||
Exception reportedException)
|
Exception reportedException, int SaveCount, int FilterCount)
|
||||||
{
|
{
|
||||||
InventoryArchiveSaved handlerInventoryArchiveSaved = OnInventoryArchiveSaved;
|
InventoryArchiveSaved handlerInventoryArchiveSaved = OnInventoryArchiveSaved;
|
||||||
if (handlerInventoryArchiveSaved != null)
|
if (handlerInventoryArchiveSaved != null)
|
||||||
handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException);
|
handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException, SaveCount , FilterCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Trigger the inventory archive loaded event.
|
||||||
|
/// </summary>
|
||||||
|
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(
|
public bool ArchiveInventory(
|
||||||
|
@ -272,13 +286,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
return false;
|
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<string, object>());
|
return DearchiveInventory(id, firstName, lastName, invPath, pass, loadStream, new Dictionary<string, object>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DearchiveInventory(
|
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<string, object> options)
|
Dictionary<string, object> options)
|
||||||
{
|
{
|
||||||
if (m_scenes.Count > 0)
|
if (m_scenes.Count > 0)
|
||||||
|
@ -294,7 +308,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
|
|
||||||
try
|
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)
|
catch (EntryPointNotFoundException e)
|
||||||
{
|
{
|
||||||
|
@ -326,7 +340,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DearchiveInventory(
|
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<string, object> options)
|
Dictionary<string, object> options)
|
||||||
{
|
{
|
||||||
if (m_scenes.Count > 0)
|
if (m_scenes.Count > 0)
|
||||||
|
@ -342,7 +356,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
|
|
||||||
try
|
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)
|
catch (EntryPointNotFoundException e)
|
||||||
{
|
{
|
||||||
|
@ -378,6 +392,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
UUID id = UUID.Random();
|
||||||
|
|
||||||
Dictionary<string, object> options = new Dictionary<string, object>();
|
Dictionary<string, object> options = new Dictionary<string, object>();
|
||||||
OptionSet optionSet = new OptionSet().Add("m|merge", delegate (string v) { options["merge"] = v != null; });
|
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}",
|
"[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}",
|
||||||
loadPath, invPath, firstName, lastName);
|
loadPath, invPath, firstName, lastName);
|
||||||
|
|
||||||
if (DearchiveInventory(firstName, lastName, invPath, pass, loadPath, options))
|
lock (m_pendingConsoleTasks)
|
||||||
m_log.InfoFormat(
|
m_pendingConsoleTasks.Add(id);
|
||||||
"[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}",
|
|
||||||
loadPath, firstName, lastName);
|
DearchiveInventory(id, firstName, lastName, invPath, pass, loadPath, options);
|
||||||
}
|
}
|
||||||
catch (InventoryArchiverException e)
|
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}",
|
"[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}",
|
||||||
savePath, invPath, firstName, lastName);
|
savePath, invPath, firstName, lastName);
|
||||||
|
|
||||||
lock (m_pendingConsoleSaves)
|
lock (m_pendingConsoleTasks)
|
||||||
m_pendingConsoleSaves.Add(id);
|
m_pendingConsoleTasks.Add(id);
|
||||||
|
|
||||||
ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, options);
|
ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, options);
|
||||||
}
|
}
|
||||||
|
@ -478,19 +494,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
|
|
||||||
private void SaveInvConsoleCommandCompleted(
|
private void SaveInvConsoleCommandCompleted(
|
||||||
UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
|
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))
|
if (m_pendingConsoleTasks.Contains(id))
|
||||||
m_pendingConsoleSaves.Remove(id);
|
m_pendingConsoleTasks.Remove(id);
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (succeeded)
|
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
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get user information for the given name.
|
/// Get user information for the given name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -70,7 +70,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "meowfood");
|
UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "meowfood");
|
||||||
UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1, "hampshire");
|
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
|
InventoryItemBase foundItem1
|
||||||
= InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
|
= 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
|
// Now try loading to a root child folder
|
||||||
UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xA", false);
|
UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xA", false);
|
||||||
MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray());
|
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
|
InventoryItemBase foundItem2
|
||||||
= InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, "xA/" + m_item1Name);
|
= 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
|
// Now try loading to a more deeply nested folder
|
||||||
UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC", false);
|
UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC", false);
|
||||||
archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
|
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
|
InventoryItemBase foundItem3
|
||||||
= InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC/" + m_item1Name);
|
= 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);
|
SceneHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
|
||||||
|
|
||||||
UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "password");
|
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
|
InventoryItemBase foundItem1
|
||||||
= InventoryArchiveUtils.FindItemByPath(
|
= InventoryArchiveUtils.FindItemByPath(
|
||||||
|
@ -186,7 +186,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
// LOAD ITEM
|
// LOAD ITEM
|
||||||
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
|
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
|
||||||
|
|
||||||
archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream);
|
archiverModule.DearchiveInventory(UUID.Random(), userFirstName, userLastName, "Scripts", userPassword, archiveReadStream);
|
||||||
|
|
||||||
InventoryItemBase foundItem1
|
InventoryItemBase foundItem1
|
||||||
= InventoryArchiveUtils.FindItemByPath(
|
= InventoryArchiveUtils.FindItemByPath(
|
||||||
|
@ -229,7 +229,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
|
|
||||||
{
|
{
|
||||||
// Test replication of path1
|
// 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(
|
.ReplicateArchivePathToUserInventory(
|
||||||
iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
|
iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
|
||||||
foldersCreated, nodesLoaded);
|
foldersCreated, nodesLoaded);
|
||||||
|
@ -246,7 +246,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
|
|
||||||
{
|
{
|
||||||
// Test replication of path2
|
// 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(
|
.ReplicateArchivePathToUserInventory(
|
||||||
iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
|
iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
|
||||||
foldersCreated, nodesLoaded);
|
foldersCreated, nodesLoaded);
|
||||||
|
@ -292,7 +292,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
|
|
||||||
string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
|
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(
|
.ReplicateArchivePathToUserInventory(
|
||||||
itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
|
itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
|
||||||
new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
|
new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
|
||||||
|
@ -343,7 +343,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
|
|
||||||
string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
|
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(
|
.ReplicateArchivePathToUserInventory(
|
||||||
itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
|
itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
|
||||||
new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
|
new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
// TestHelpers.EnableLogging();
|
// TestHelpers.EnableLogging();
|
||||||
|
|
||||||
UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "password");
|
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
|
InventoryItemBase coaItem
|
||||||
= InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_coaItemName);
|
= InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_coaItemName);
|
||||||
|
@ -107,7 +107,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
|
|
||||||
UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "meowfood");
|
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
|
InventoryItemBase foundItem1
|
||||||
= InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_item1Name);
|
= 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();
|
// log4net.Config.XmlConfigurator.Configure();
|
||||||
|
|
||||||
UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "password");
|
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
|
InventoryItemBase foundItem1
|
||||||
= InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
|
= InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
|
||||||
|
|
|
@ -86,7 +86,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH));
|
Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH));
|
||||||
|
|
||||||
InventoryArchiveReadRequest iarr
|
InventoryArchiveReadRequest iarr
|
||||||
= new InventoryArchiveReadRequest(null, null, null, null, null, (Stream)null, false);
|
= new InventoryArchiveReadRequest(UUID.Random(), null, null, null, null, null, null, (Stream)null, false);
|
||||||
iarr.LoadControlFile(filePath, data);
|
iarr.LoadControlFile(filePath, data);
|
||||||
|
|
||||||
Assert.That(iarr.ControlFileLoaded, Is.True);
|
Assert.That(iarr.ControlFileLoaded, Is.True);
|
||||||
|
|
|
@ -170,7 +170,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
|
|
||||||
protected void SaveCompleted(
|
protected void SaveCompleted(
|
||||||
UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
|
UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
|
||||||
Exception reportedException)
|
Exception reportedException, int SaveCount, int FilterCount)
|
||||||
{
|
{
|
||||||
mre.Set();
|
mre.Set();
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,7 +176,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library
|
||||||
m_log.InfoFormat("[LIBRARY MODULE]: Loading library archive {0} ({1})...", iarFileName, simpleName);
|
m_log.InfoFormat("[LIBRARY MODULE]: Loading library archive {0} ({1})...", iarFileName, simpleName);
|
||||||
simpleName = GetInventoryPathFromName(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
|
try
|
||||||
{
|
{
|
||||||
HashSet<InventoryNodeBase> nodes = archread.Execute();
|
HashSet<InventoryNodeBase> 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
|
// 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);
|
m_log.InfoFormat("[LIBRARY MODULE]: Didn't find {0} in library. Placing archive on the top level", simpleName);
|
||||||
archread.Close();
|
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();
|
archread.Execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,24 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
/// <param name="invPath">The inventory path saved</param>
|
/// <param name="invPath">The inventory path saved</param>
|
||||||
/// <param name="savePath">The stream to which the archive was saved</param>
|
/// <param name="savePath">The stream to which the archive was saved</param>
|
||||||
/// <param name="reportedException">Contains the exception generated if the save did not succeed</param>
|
/// <param name="reportedException">Contains the exception generated if the save did not succeed</param>
|
||||||
|
/// <param name="SaveCount">Number of inventory items saved to archive</param>
|
||||||
|
/// <param name="FilterCount">Number of inventory items skipped due to perm filter option</param>
|
||||||
public delegate void InventoryArchiveSaved(
|
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);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used for the OnInventoryArchiveLoaded event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Request id</param>
|
||||||
|
/// <param name="succeeded">true if the load succeeded, false otherwise</param>
|
||||||
|
/// <param name="userInfo">The user for whom the load was conducted</param>
|
||||||
|
/// <param name="invPath">The inventory path loaded</param>
|
||||||
|
/// <param name="savePath">The stream from which the archive was loaded</param>
|
||||||
|
/// <param name="reportedException">Contains the exception generated if the load did not succeed</param>
|
||||||
|
/// <param name="LoadCount">Number of inventory items loaded from archive</param>
|
||||||
|
public delegate void InventoryArchiveLoaded(
|
||||||
|
UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream loadStream, Exception reportedException, int LoadCount);
|
||||||
|
|
||||||
|
|
||||||
public interface IInventoryArchiverModule
|
public interface IInventoryArchiverModule
|
||||||
{
|
{
|
||||||
|
@ -52,6 +68,11 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
/// </summary>
|
/// </summary>
|
||||||
event InventoryArchiveSaved OnInventoryArchiveSaved;
|
event InventoryArchiveSaved OnInventoryArchiveSaved;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fired when an archive inventory load has been completed.
|
||||||
|
/// </summary>
|
||||||
|
event InventoryArchiveLoaded OnInventoryArchiveLoaded;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dearchive a user's inventory folder from the given stream
|
/// Dearchive a user's inventory folder from the given stream
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -60,7 +81,7 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
/// <param name="invPath">The inventory path in which to place the loaded folders and items</param>
|
/// <param name="invPath">The inventory path in which to place the loaded folders and items</param>
|
||||||
/// <param name="loadStream">The stream from which the inventory archive will be loaded</param>
|
/// <param name="loadStream">The stream from which the inventory archive will be loaded</param>
|
||||||
/// <returns>true if the first stage of the operation succeeded, false otherwise</returns>
|
/// <returns>true if the first stage of the operation succeeded, false otherwise</returns>
|
||||||
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);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dearchive a user's inventory folder from the given stream
|
/// 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.</param>
|
/// the loaded IAR with existing folders where possible.</param>
|
||||||
/// <returns>true if the first stage of the operation succeeded, false otherwise</returns>
|
/// <returns>true if the first stage of the operation succeeded, false otherwise</returns>
|
||||||
bool DearchiveInventory(
|
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<string, object> options);
|
Dictionary<string, object> options);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue