From a366c05ae2fdfbcce1bc592166f89e3e286bcae4 Mon Sep 17 00:00:00 2001
From: Kevin Cozens
Date: Fri, 10 Feb 2012 14:09:46 -0500
Subject: Added ability to exclude inventory items or folders when saving IAR
files.
---
.../Inventory/Archiver/InventoryArchiverModule.cs | 124 ++++++++++++---------
1 file changed, 69 insertions(+), 55 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index ac22c3f..cf87010 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -47,18 +47,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
public class InventoryArchiverModule : IRegionModule, IInventoryArchiverModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
+
public string Name { get { return "Inventory Archiver Module"; } }
-
+
public bool IsSharedModule { get { return true; } }
///
- /// Enable or disable checking whether the iar user is actually logged in
+ /// Enable or disable checking whether the iar user is actually logged in
///
// public bool DisablePresenceChecks { get; set; }
-
+
public event InventoryArchiveSaved OnInventoryArchiveSaved;
-
+
///
/// The file to load and save inventory if no filename has been specified
///
@@ -68,7 +68,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
/// Pending save completions initiated from the console
///
protected List m_pendingConsoleSaves = new List();
-
+
///
/// All scenes that this module knows about
///
@@ -106,7 +106,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
{
scene.RegisterModuleInterface(this);
OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted;
-
+
scene.AddCommand(
"Archiving", this, "load iar",
"load iar [-m|--merge] []",
@@ -119,11 +119,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
+ " is the filesystem path or URI from which to load the IAR."
+ string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME),
HandleLoadInvConsoleCommand);
-
+
scene.AddCommand(
"Archiving", this, "save iar",
- "save iar [-h|--home=] [--noassets] [] [-c|--creators] [-v|--verbose]",
- "Save user inventory archive (IAR).",
+ "save iar [-h|--home=] [--noassets] [] [-c|--creators] [-e|--exclude=] [-f|--excludefolder=] [-v|--verbose]",
+ "Save user inventory archive (IAR).",
" is the user's first name.\n"
+ " is the user's last name.\n"
+ " is the path inside the user's inventory for the folder/item to be saved.\n"
@@ -131,32 +131,34 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
+ string.Format(" If this is not given then the filename {0} in the current directory is used.\n", DEFAULT_INV_BACKUP_FILENAME)
+ "-h|--home= adds the url of the profile service to the saved user information.\n"
+ "-c|--creators preserves information about foreign creators.\n"
+ + "-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.\n"
+ "--noassets stops assets being saved to the IAR.",
HandleSaveInvConsoleCommand);
m_aScene = scene;
}
-
+
m_scenes[scene.RegionInfo.RegionID] = scene;
}
public void PostInitialise() {}
public void Close() {}
-
+
///
/// Trigger the inventory archive saved event.
///
protected internal void TriggerInventoryArchiveSaved(
- Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
+ Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
Exception reportedException)
{
InventoryArchiveSaved handlerInventoryArchiveSaved = OnInventoryArchiveSaved;
if (handlerInventoryArchiveSaved != null)
handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException);
}
-
+
public bool ArchiveInventory(
Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream)
{
@@ -164,7 +166,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
}
public bool ArchiveInventory(
- Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream,
+ Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream,
Dictionary options)
{
if (m_scenes.Count > 0)
@@ -188,7 +190,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
return false;
}
-
+
return true;
// }
// else
@@ -202,15 +204,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
return false;
}
-
+
public bool ArchiveInventory(
- Guid id, string firstName, string lastName, string invPath, string pass, string savePath,
+ Guid id, string firstName, string lastName, string invPath, string pass, string savePath,
Dictionary options)
{
if (m_scenes.Count > 0)
{
UserAccount userInfo = GetUserInfo(firstName, lastName, pass);
-
+
if (userInfo != null)
{
// if (CheckPresence(userInfo.PrincipalID))
@@ -228,7 +230,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
return false;
}
-
+
return true;
// }
// else
@@ -239,7 +241,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
// }
}
}
-
+
return false;
}
@@ -247,9 +249,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
{
return DearchiveInventory(firstName, lastName, invPath, pass, loadStream, new Dictionary());
}
-
+
public bool DearchiveInventory(
- string firstName, string lastName, string invPath, string pass, Stream loadStream,
+ string firstName, string lastName, string invPath, string pass, Stream loadStream,
Dictionary options)
{
if (m_scenes.Count > 0)
@@ -295,22 +297,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
return false;
}
-
+
public bool DearchiveInventory(
- string firstName, string lastName, string invPath, string pass, string loadPath,
+ string firstName, string lastName, string invPath, string pass, string loadPath,
Dictionary options)
{
if (m_scenes.Count > 0)
{
UserAccount userInfo = GetUserInfo(firstName, lastName, pass);
-
+
if (userInfo != null)
{
// if (CheckPresence(userInfo.PrincipalID))
// {
InventoryArchiveReadRequest request;
bool merge = (options.ContainsKey("merge") ? (bool)options["merge"] : false);
-
+
try
{
request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath, merge);
@@ -324,7 +326,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
return false;
}
-
+
UpdateClientWithLoadedNodes(userInfo, request.Execute());
return true;
@@ -340,7 +342,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
return false;
}
-
+
///
/// Load inventory from an inventory file archive
///
@@ -351,26 +353,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
{
Dictionary options = new Dictionary();
OptionSet optionSet = new OptionSet().Add("m|merge", delegate (string v) { options["merge"] = v != null; });
-
+
List mainParams = optionSet.Parse(cmdparams);
-
+
if (mainParams.Count < 6)
{
m_log.Error(
- "[INVENTORY ARCHIVER]: usage is load iar [-m|--merge] []");
+ "[INVENTORY ARCHIVER]: usage is load iar [-m|--merge] []");
return;
}
-
+
string firstName = mainParams[2];
string lastName = mainParams[3];
string invPath = mainParams[4];
string pass = mainParams[5];
string loadPath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME);
-
+
m_log.InfoFormat(
"[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}",
@@ -381,7 +383,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", e.Message);
}
}
-
+
///
/// Save inventory to a file archive
///
@@ -398,6 +400,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
ops.Add("v|verbose", delegate(string v) { options["verbose"] = v; });
ops.Add("c|creators", delegate(string v) { options["creators"] = v; });
ops.Add("noassets", delegate(string v) { options["noassets"] = v != null; });
+ ops.Add("e|exclude=", delegate(string v)
+ {
+ if (!options.ContainsKey("exclude"))
+ options["exclude"] = new List();
+ ((List)options["exclude"]).Add(v);
+ });
+ ops.Add("f|excludefolder=", delegate(string v)
+ {
+ if (!options.ContainsKey("excludefolders"))
+ options["excludefolders"] = new List();
+ ((List)options["excludefolders"]).Add(v);
+ });
List mainParams = ops.Parse(cmdparams);
@@ -406,10 +420,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
if (mainParams.Count < 6)
{
m_log.Error(
- "[INVENTORY ARCHIVER]: usage is save iar [-h|--home=] [--noassets] [] [-c|--creators] [-v|--verbose]");
+ "[INVENTORY ARCHIVER]: save iar [-h|--home=] [--noassets] [] [-c|--creators] [-e|--exclude=] [-f|--excludefolder=] [-v|--verbose]");
return;
}
-
+
if (options.ContainsKey("home"))
m_log.WarnFormat("[INVENTORY ARCHIVER]: Please be aware that inventory archives with creator information are not compatible with OpenSim 0.7.0.2 and earlier. Do not use the -home option if you want to produce a compatible IAR");
@@ -418,7 +432,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
string invPath = mainParams[4];
string pass = mainParams[5];
string savePath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME);
-
+
m_log.InfoFormat(
"[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}",
savePath, invPath, firstName, lastName);
@@ -433,9 +447,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", e.Message);
}
}
-
+
private void SaveInvConsoleCommandCompleted(
- Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
+ Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
Exception reportedException)
{
lock (m_pendingConsoleSaves)
@@ -445,7 +459,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
else
return;
}
-
+
if (succeeded)
{
m_log.InfoFormat("[INVENTORY ARCHIVER]: Saved archive for {0} {1}", userInfo.FirstName, userInfo.LastName);
@@ -453,11 +467,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
else
{
m_log.ErrorFormat(
- "[INVENTORY ARCHIVER]: Archive save for {0} {1} failed - {2}",
+ "[INVENTORY ARCHIVER]: Archive save for {0} {1} failed - {2}",
userInfo.FirstName, userInfo.LastName, reportedException.Message);
}
}
-
+
///
/// Get user information for the given name.
///
@@ -467,13 +481,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
///
protected UserAccount GetUserInfo(string firstName, string lastName, string pass)
{
- UserAccount account
+ UserAccount account
= m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, firstName, lastName);
-
+
if (null == account)
{
m_log.ErrorFormat(
- "[INVENTORY ARCHIVER]: Failed to find user info for {0} {1}",
+ "[INVENTORY ARCHIVER]: Failed to find user info for {0} {1}",
firstName, lastName);
return null;
}
@@ -488,7 +502,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
else
{
m_log.ErrorFormat(
- "[INVENTORY ARCHIVER]: Password for user {0} {1} incorrect. Please try again.",
+ "[INVENTORY ARCHIVER]: Password for user {0} {1} incorrect. Please try again.",
firstName, lastName);
return null;
}
@@ -499,7 +513,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
return null;
}
}
-
+
///
/// Notify the client of loaded nodes if they are logged in
///
@@ -508,22 +522,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
{
if (loadedNodes.Count == 0)
return;
-
+
foreach (Scene scene in m_scenes.Values)
{
ScenePresence user = scene.GetScenePresence(userInfo.PrincipalID);
-
+
if (user != null && !user.IsChildAgent)
{
foreach (InventoryNodeBase node in loadedNodes)
{
// m_log.DebugFormat(
-// "[INVENTORY ARCHIVER]: Notifying {0} of loaded inventory node {1}",
+// "[INVENTORY ARCHIVER]: Notifying {0} of loaded inventory node {1}",
// user.Name, node.Name);
-
+
user.ControllingClient.SendBulkUpdateInventory(node);
}
-
+
break;
}
}
@@ -538,7 +552,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
// {
// if (DisablePresenceChecks)
// return true;
-//
+//
// foreach (Scene scene in m_scenes.Values)
// {
// ScenePresence p;
--
cgit v1.1