Compare commits

...

3 Commits

Author SHA1 Message Date
BlueWall e2e8a33a1c Merge branch 'master' of /home/opensim/var/repo/opensim
Conflicts:
	OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
	OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
2012-03-13 15:35:21 -04:00
Kevin Cozens 910a5c842a Track inventory folders to give more control over what is saved to IAR. 2012-03-13 15:28:09 -04:00
Kevin Cozens 2a2f4f6fda Added ability to exclude inventory items or folders when saving IAR files. 2012-03-13 15:26:28 -04:00
2 changed files with 155 additions and 89 deletions

View File

@ -144,8 +144,28 @@ 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<string, object> options, IUserAccountService userAccountService)
protected void SaveInvItem(
InventoryItemBase inventoryItem, string path, Dictionary<string, object> options,
IUserAccountService userAccountService, string folderPath)
{
if (options.ContainsKey("exclude"))
{
//Full details of current item is folder path plus item name.
folderPath = CreateFolderPath(folderPath, inventoryItem.Name);
if (((List<String>)options["exclude"]).Contains(folderPath) ||
((List<String>)options["exclude"]).Contains(inventoryItem.ID.ToString()))
{
if (options.ContainsKey("verbose"))
{
m_log.InfoFormat(
"[INVENTORY ARCHIVER]: Skipping inventory item {0} {1} at {2}",
inventoryItem.Name, inventoryItem.ID, path);
}
return;
}
}
if (options.ContainsKey("verbose"))
m_log.InfoFormat(
"[INVENTORY ARCHIVER]: Saving item {0} {1} with asset {2}",
@ -174,10 +194,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
/// <param name="saveThisFolderItself">If true, save this folder itself. If false, only saves contents</param>
/// <param name="options"></param>
/// <param name="userAccountService"></param>
/// <param name="folderPath">Path to previous (parent) folder</param>
protected void SaveInvFolder(
InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself,
Dictionary<string, object> options, IUserAccountService userAccountService)
Dictionary<string, object> 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<String>)options["excludefolders"]).Contains(folderPath) ||
((List<String>)options["excludefolders"]).Contains(inventoryFolder.ID.ToString()))
{
if (options.ContainsKey("verbose"))
{
m_log.InfoFormat(
"[INVENTORY ARCHIVER]: Skipping folder {0} at {1}",
inventoryFolder.Name, path);
}
return;
}
}
if (options.ContainsKey("verbose"))
m_log.InfoFormat("[INVENTORY ARCHIVER]: Saving folder {0}", inventoryFolder.Name);
@ -194,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);
}
}
@ -286,7 +325,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)
{
@ -294,7 +333,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.
@ -407,6 +446,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
id);
}
/// <summary>
/// Create the path to the inventory folder about to be processed
/// </summary>
/// <param name="folderPath"></param>
/// <param name="subFolder"></param>
/// <returns></returns>
public string CreateFolderPath(string folderPath, string subFolder)
{
if (folderPath != "")
folderPath += "/";
return folderPath + subFolder;
}
/// <summary>
/// Create the control file for the archive
/// </summary>

View File

@ -129,8 +129,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
+ "<inventory path> is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine
+ "-h|--home=<url> adds the url of the profile service to the saved user information." + Environment.NewLine
+ "-c|--creators preserves information about foreign creators." + Environment.NewLine
+ "-e|--exclude=<name/uuid> don't save the inventory item in archive" + Environment.NewLine
+ "-f|--excludefolder=<folder/uuid> 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
+ "<IAR path> 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);
@ -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<String>();
((List<String>)options["exclude"]).Add(v);
});
ops.Add("f|excludefolder=", delegate(string v)
{
if (!options.ContainsKey("excludefolders"))
options["excludefolders"] = new List<String>();
((List<String>)options["excludefolders"]).Add(v);
});
List<string> mainParams = ops.Parse(cmdparams);
@ -406,10 +420,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
if (mainParams.Count < 6)
{
m_log.Error(
"[INVENTORY ARCHIVER]: usage is save iar [-h|--home=<url>] [--noassets] <first name> <last name> <inventory path> <user password> [<save file path>] [-c|--creators] [-v|--verbose]");
"[INVENTORY ARCHIVER]: save iar [-h|--home=<url>] [--noassets] <first> <last> <inventory path> <password> [<IAR path>] [-c|--creators] [-e|--exclude=<name/uuid>] [-f|--excludefolder=<foldername/uuid>] [-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");