in IAR utils, return all folders that match a particular path rather than just the first one
parent
e3432b8f63
commit
cf4721a92d
|
@ -100,11 +100,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|||
|
||||
List<InventoryNodeBase> loadedNodes = new List<InventoryNodeBase>();
|
||||
|
||||
InventoryFolderBase rootDestinationFolder
|
||||
List<InventoryFolderBase> folderCandidates
|
||||
= InventoryArchiveUtils.FindFolderByPath(
|
||||
m_scene.InventoryService, m_userInfo.PrincipalID, m_invPath);
|
||||
|
||||
if (null == rootDestinationFolder)
|
||||
if (folderCandidates.Count == 0)
|
||||
{
|
||||
// Possibly provide an option later on to automatically create this folder if it does not exist
|
||||
m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath);
|
||||
|
@ -112,6 +112,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|||
return loadedNodes;
|
||||
}
|
||||
|
||||
InventoryFolderBase rootDestinationFolder = folderCandidates[0];
|
||||
archive = new TarArchiveReader(m_loadStream);
|
||||
|
||||
// In order to load identically named folders, we need to keep track of the folders that we have already
|
||||
|
@ -246,6 +247,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|||
ref string archivePath,
|
||||
Dictionary <string, InventoryFolderBase> resolvedFolders)
|
||||
{
|
||||
m_log.DebugFormat("[INVENTORY ARCHIVER]: Resolving destination folder {0}", archivePath);
|
||||
|
||||
string originalArchivePath = archivePath;
|
||||
|
||||
InventoryFolderBase destFolder = null;
|
||||
|
@ -256,8 +259,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|||
{
|
||||
if (resolvedFolders.ContainsKey(archivePath))
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[INVENTORY ARCHIVER]: Found previously created folder from archive path {0}", archivePath);
|
||||
m_log.DebugFormat(
|
||||
"[INVENTORY ARCHIVER]: Found previously created folder from archive path {0}", archivePath);
|
||||
destFolder = resolvedFolders[archivePath];
|
||||
}
|
||||
else
|
||||
|
|
|
@ -55,8 +55,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|||
///
|
||||
/// This method does not handle paths that contain multiple delimitors
|
||||
///
|
||||
/// FIXME: We do not yet handle situations where folders have the same name. We could handle this by some
|
||||
/// XPath like expression
|
||||
/// FIXME: We have no way of distinguishing folders with the same path
|
||||
///
|
||||
/// FIXME: Delimitors which occur in names themselves are not currently escapable.
|
||||
///
|
||||
|
@ -70,14 +69,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|||
/// The path to the required folder.
|
||||
/// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned.
|
||||
/// </param>
|
||||
/// <returns>null if the folder is not found</returns>
|
||||
public static InventoryFolderBase FindFolderByPath(
|
||||
/// <returns>An empty list if the folder is not found, otherwise a list of all folders that match the name</returns>
|
||||
public static List<InventoryFolderBase> FindFolderByPath(
|
||||
IInventoryService inventoryService, UUID userId, string path)
|
||||
{
|
||||
InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId);
|
||||
|
||||
if (null == rootFolder)
|
||||
return null;
|
||||
return new List<InventoryFolderBase>();
|
||||
|
||||
return FindFolderByPath(inventoryService, rootFolder, path);
|
||||
}
|
||||
|
@ -88,8 +87,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|||
///
|
||||
/// This method does not handle paths that contain multiple delimitors
|
||||
///
|
||||
/// FIXME: We do not yet handle situations where folders have the same name. We could handle this by some
|
||||
/// XPath like expression
|
||||
/// FIXME: We have no way of distinguishing folders with the same path.
|
||||
///
|
||||
/// FIXME: Delimitors which occur in names themselves are not currently escapable.
|
||||
///
|
||||
|
@ -103,17 +101,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|||
/// The path to the required folder.
|
||||
/// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned.
|
||||
/// </param>
|
||||
/// <returns>null if the folder is not found</returns>
|
||||
public static InventoryFolderBase FindFolderByPath(
|
||||
/// <returns>An empty list if the folder is not found, otherwise a list of all folders that match the name</returns>
|
||||
public static List<InventoryFolderBase> FindFolderByPath(
|
||||
IInventoryService inventoryService, InventoryFolderBase startFolder, string path)
|
||||
{
|
||||
List<InventoryFolderBase> foundFolders = new List<InventoryFolderBase>();
|
||||
|
||||
if (path == string.Empty)
|
||||
return startFolder;
|
||||
{
|
||||
foundFolders.Add(startFolder);
|
||||
return foundFolders;
|
||||
}
|
||||
|
||||
path = path.Trim();
|
||||
|
||||
if (path == PATH_DELIMITER.ToString())
|
||||
return startFolder;
|
||||
{
|
||||
foundFolders.Add(startFolder);
|
||||
return foundFolders;
|
||||
}
|
||||
|
||||
string[] components = SplitEscapedPath(path);
|
||||
components[0] = UnescapePath(components[0]);
|
||||
|
@ -127,14 +133,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|||
if (folder.Name == components[0])
|
||||
{
|
||||
if (components.Length > 1)
|
||||
return FindFolderByPath(inventoryService, folder, components[1]);
|
||||
foundFolders.AddRange(FindFolderByPath(inventoryService, folder, components[1]));
|
||||
else
|
||||
return folder;
|
||||
foundFolders.Add(folder);
|
||||
}
|
||||
}
|
||||
|
||||
// We didn't find a folder with the right name
|
||||
return null;
|
||||
return foundFolders;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -249,9 +249,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|||
else
|
||||
{
|
||||
m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER));
|
||||
inventoryFolder
|
||||
List<InventoryFolderBase> candidateFolders
|
||||
= InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, rootFolder, m_invPath);
|
||||
//inventoryFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath);
|
||||
if (candidateFolders.Count > 0)
|
||||
inventoryFolder = candidateFolders[0];
|
||||
}
|
||||
|
||||
// The path may point to an item instead
|
||||
|
|
|
@ -117,7 +117,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
|||
item1.AssetID = asset1.FullID;
|
||||
item1.ID = item1Id;
|
||||
InventoryFolderBase objsFolder
|
||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects");
|
||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
|
||||
item1.Folder = objsFolder.ID;
|
||||
scene.AddInventoryItem(userId, item1);
|
||||
|
||||
|
@ -327,7 +327,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
|||
item1.AssetID = asset1.FullID;
|
||||
item1.ID = item1Id;
|
||||
InventoryFolderBase objsFolder
|
||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects");
|
||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
|
||||
item1.Folder = objsFolder.ID;
|
||||
scene.AddInventoryItem(userId, item1);
|
||||
|
||||
|
@ -535,9 +535,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
|||
foldersCreated, nodesLoaded);
|
||||
|
||||
InventoryFolderBase folder1
|
||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, "a");
|
||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, "a")[0];
|
||||
Assert.That(folder1, Is.Not.Null, "Could not find folder a");
|
||||
InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b");
|
||||
InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b")[0];
|
||||
Assert.That(folder2, Is.Not.Null, "Could not find folder b");
|
||||
}
|
||||
|
||||
|
@ -576,7 +576,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
|||
new Dictionary<string, InventoryFolderBase>(), new List<InventoryNodeBase>());
|
||||
|
||||
InventoryFolderBase folder1Post
|
||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
|
||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName)[0];
|
||||
Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID));
|
||||
/*
|
||||
InventoryFolderBase folder2
|
||||
|
|
Loading…
Reference in New Issue