aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Inventory
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-06-18 16:33:34 +0100
committerJustin Clark-Casey2010-06-18 18:08:37 +0100
commite98109765c11b4ea9abac3bb24600b1414ef4a36 (patch)
tree2255b7921dee5e7a206d36aebc1232910d786a4d /OpenSim/Region/CoreModules/Avatar/Inventory
parentMerge branch '0.7-post-fixes' of ssh://diva@opensimulator.org/var/git/opensim... (diff)
downloadopensim-SC-e98109765c11b4ea9abac3bb24600b1414ef4a36.zip
opensim-SC-e98109765c11b4ea9abac3bb24600b1414ef4a36.tar.gz
opensim-SC-e98109765c11b4ea9abac3bb24600b1414ef4a36.tar.bz2
opensim-SC-e98109765c11b4ea9abac3bb24600b1414ef4a36.tar.xz
in IAR utils, return all folders that match a particular path rather than just the first one
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs13
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs35
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs5
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs10
4 files changed, 36 insertions, 27 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index b4f1ed6..29e992e 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -100,18 +100,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
100 100
101 List<InventoryNodeBase> loadedNodes = new List<InventoryNodeBase>(); 101 List<InventoryNodeBase> loadedNodes = new List<InventoryNodeBase>();
102 102
103 InventoryFolderBase rootDestinationFolder 103 List<InventoryFolderBase> folderCandidates
104 = InventoryArchiveUtils.FindFolderByPath( 104 = InventoryArchiveUtils.FindFolderByPath(
105 m_scene.InventoryService, m_userInfo.PrincipalID, m_invPath); 105 m_scene.InventoryService, m_userInfo.PrincipalID, m_invPath);
106 106
107 if (null == rootDestinationFolder) 107 if (folderCandidates.Count == 0)
108 { 108 {
109 // Possibly provide an option later on to automatically create this folder if it does not exist 109 // Possibly provide an option later on to automatically create this folder if it does not exist
110 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath); 110 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath);
111 111
112 return loadedNodes; 112 return loadedNodes;
113 } 113 }
114 114
115 InventoryFolderBase rootDestinationFolder = folderCandidates[0];
115 archive = new TarArchiveReader(m_loadStream); 116 archive = new TarArchiveReader(m_loadStream);
116 117
117 // In order to load identically named folders, we need to keep track of the folders that we have already 118 // 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
246 ref string archivePath, 247 ref string archivePath,
247 Dictionary <string, InventoryFolderBase> resolvedFolders) 248 Dictionary <string, InventoryFolderBase> resolvedFolders)
248 { 249 {
250 m_log.DebugFormat("[INVENTORY ARCHIVER]: Resolving destination folder {0}", archivePath);
251
249 string originalArchivePath = archivePath; 252 string originalArchivePath = archivePath;
250 253
251 InventoryFolderBase destFolder = null; 254 InventoryFolderBase destFolder = null;
@@ -256,8 +259,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
256 { 259 {
257 if (resolvedFolders.ContainsKey(archivePath)) 260 if (resolvedFolders.ContainsKey(archivePath))
258 { 261 {
259// m_log.DebugFormat( 262 m_log.DebugFormat(
260// "[INVENTORY ARCHIVER]: Found previously created folder from archive path {0}", archivePath); 263 "[INVENTORY ARCHIVER]: Found previously created folder from archive path {0}", archivePath);
261 destFolder = resolvedFolders[archivePath]; 264 destFolder = resolvedFolders[archivePath];
262 } 265 }
263 else 266 else
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs
index 47b18d8..ca33968 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs
@@ -55,8 +55,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
55 /// 55 ///
56 /// This method does not handle paths that contain multiple delimitors 56 /// This method does not handle paths that contain multiple delimitors
57 /// 57 ///
58 /// FIXME: We do not yet handle situations where folders have the same name. We could handle this by some 58 /// FIXME: We have no way of distinguishing folders with the same path
59 /// XPath like expression
60 /// 59 ///
61 /// FIXME: Delimitors which occur in names themselves are not currently escapable. 60 /// FIXME: Delimitors which occur in names themselves are not currently escapable.
62 /// 61 ///
@@ -70,14 +69,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
70 /// The path to the required folder. 69 /// The path to the required folder.
71 /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned. 70 /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned.
72 /// </param> 71 /// </param>
73 /// <returns>null if the folder is not found</returns> 72 /// <returns>An empty list if the folder is not found, otherwise a list of all folders that match the name</returns>
74 public static InventoryFolderBase FindFolderByPath( 73 public static List<InventoryFolderBase> FindFolderByPath(
75 IInventoryService inventoryService, UUID userId, string path) 74 IInventoryService inventoryService, UUID userId, string path)
76 { 75 {
77 InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); 76 InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId);
78 77
79 if (null == rootFolder) 78 if (null == rootFolder)
80 return null; 79 return new List<InventoryFolderBase>();
81 80
82 return FindFolderByPath(inventoryService, rootFolder, path); 81 return FindFolderByPath(inventoryService, rootFolder, path);
83 } 82 }
@@ -88,8 +87,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
88 /// 87 ///
89 /// This method does not handle paths that contain multiple delimitors 88 /// This method does not handle paths that contain multiple delimitors
90 /// 89 ///
91 /// FIXME: We do not yet handle situations where folders have the same name. We could handle this by some 90 /// FIXME: We have no way of distinguishing folders with the same path.
92 /// XPath like expression
93 /// 91 ///
94 /// FIXME: Delimitors which occur in names themselves are not currently escapable. 92 /// FIXME: Delimitors which occur in names themselves are not currently escapable.
95 /// 93 ///
@@ -103,17 +101,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
103 /// The path to the required folder. 101 /// The path to the required folder.
104 /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned. 102 /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned.
105 /// </param> 103 /// </param>
106 /// <returns>null if the folder is not found</returns> 104 /// <returns>An empty list if the folder is not found, otherwise a list of all folders that match the name</returns>
107 public static InventoryFolderBase FindFolderByPath( 105 public static List<InventoryFolderBase> FindFolderByPath(
108 IInventoryService inventoryService, InventoryFolderBase startFolder, string path) 106 IInventoryService inventoryService, InventoryFolderBase startFolder, string path)
109 { 107 {
108 List<InventoryFolderBase> foundFolders = new List<InventoryFolderBase>();
109
110 if (path == string.Empty) 110 if (path == string.Empty)
111 return startFolder; 111 {
112 foundFolders.Add(startFolder);
113 return foundFolders;
114 }
112 115
113 path = path.Trim(); 116 path = path.Trim();
114 117
115 if (path == PATH_DELIMITER.ToString()) 118 if (path == PATH_DELIMITER.ToString())
116 return startFolder; 119 {
120 foundFolders.Add(startFolder);
121 return foundFolders;
122 }
117 123
118 string[] components = SplitEscapedPath(path); 124 string[] components = SplitEscapedPath(path);
119 components[0] = UnescapePath(components[0]); 125 components[0] = UnescapePath(components[0]);
@@ -127,14 +133,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
127 if (folder.Name == components[0]) 133 if (folder.Name == components[0])
128 { 134 {
129 if (components.Length > 1) 135 if (components.Length > 1)
130 return FindFolderByPath(inventoryService, folder, components[1]); 136 foundFolders.AddRange(FindFolderByPath(inventoryService, folder, components[1]));
131 else 137 else
132 return folder; 138 foundFolders.Add(folder);
133 } 139 }
134 } 140 }
135 141
136 // We didn't find a folder with the right name 142 return foundFolders;
137 return null;
138 } 143 }
139 144
140 /// <summary> 145 /// <summary>
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
index 8f3f65b..2c2724e 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
@@ -249,9 +249,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
249 else 249 else
250 { 250 {
251 m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER)); 251 m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER));
252 inventoryFolder 252 List<InventoryFolderBase> candidateFolders
253 = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, rootFolder, m_invPath); 253 = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, rootFolder, m_invPath);
254 //inventoryFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); 254 if (candidateFolders.Count > 0)
255 inventoryFolder = candidateFolders[0];
255 } 256 }
256 257
257 // The path may point to an item instead 258 // The path may point to an item instead
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index 00bd27a..6bf1219 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -117,7 +117,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
117 item1.AssetID = asset1.FullID; 117 item1.AssetID = asset1.FullID;
118 item1.ID = item1Id; 118 item1.ID = item1Id;
119 InventoryFolderBase objsFolder 119 InventoryFolderBase objsFolder
120 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); 120 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
121 item1.Folder = objsFolder.ID; 121 item1.Folder = objsFolder.ID;
122 scene.AddInventoryItem(userId, item1); 122 scene.AddInventoryItem(userId, item1);
123 123
@@ -327,7 +327,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
327 item1.AssetID = asset1.FullID; 327 item1.AssetID = asset1.FullID;
328 item1.ID = item1Id; 328 item1.ID = item1Id;
329 InventoryFolderBase objsFolder 329 InventoryFolderBase objsFolder
330 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); 330 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
331 item1.Folder = objsFolder.ID; 331 item1.Folder = objsFolder.ID;
332 scene.AddInventoryItem(userId, item1); 332 scene.AddInventoryItem(userId, item1);
333 333
@@ -535,9 +535,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
535 foldersCreated, nodesLoaded); 535 foldersCreated, nodesLoaded);
536 536
537 InventoryFolderBase folder1 537 InventoryFolderBase folder1
538 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, "a"); 538 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, "a")[0];
539 Assert.That(folder1, Is.Not.Null, "Could not find folder a"); 539 Assert.That(folder1, Is.Not.Null, "Could not find folder a");
540 InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b"); 540 InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b")[0];
541 Assert.That(folder2, Is.Not.Null, "Could not find folder b"); 541 Assert.That(folder2, Is.Not.Null, "Could not find folder b");
542 } 542 }
543 543
@@ -576,7 +576,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
576 new Dictionary<string, InventoryFolderBase>(), new List<InventoryNodeBase>()); 576 new Dictionary<string, InventoryFolderBase>(), new List<InventoryNodeBase>());
577 577
578 InventoryFolderBase folder1Post 578 InventoryFolderBase folder1Post
579 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName); 579 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName)[0];
580 Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID)); 580 Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID));
581 /* 581 /*
582 InventoryFolderBase folder2 582 InventoryFolderBase folder2