diff options
author | Justin Clark-Casey (justincc) | 2010-06-04 23:34:42 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-06-04 23:34:42 +0100 |
commit | 3c3df9f3e9fbf9955c0939116e9bfeed1d429fa6 (patch) | |
tree | e13df3a4d21aa63e6ae91edd7a2a7aee4314aa28 /OpenSim/Region | |
parent | add ability for load iar/save iar to take in arbitrary options (diff) | |
download | opensim-SC-3c3df9f3e9fbf9955c0939116e9bfeed1d429fa6.zip opensim-SC-3c3df9f3e9fbf9955c0939116e9bfeed1d429fa6.tar.gz opensim-SC-3c3df9f3e9fbf9955c0939116e9bfeed1d429fa6.tar.bz2 opensim-SC-3c3df9f3e9fbf9955c0939116e9bfeed1d429fa6.tar.xz |
refactor: do pathname trimming outside of ReplicateArchivePathToUserInventory()
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 17 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | 2 |
2 files changed, 8 insertions, 11 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 806aa4f..256a886 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -139,10 +139,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
139 | } | 139 | } |
140 | else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) | 140 | else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) |
141 | { | 141 | { |
142 | filePath = filePath.Substring(ArchiveConstants.INVENTORY_PATH.Length); | ||
143 | |||
144 | // Trim off the file portion if we aren't already dealing with a directory path | ||
145 | if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) | ||
146 | filePath = filePath.Remove(filePath.LastIndexOf("/") + 1); | ||
147 | |||
142 | InventoryFolderBase foundFolder | 148 | InventoryFolderBase foundFolder |
143 | = ReplicateArchivePathToUserInventory( | 149 | = ReplicateArchivePathToUserInventory( |
144 | filePath, TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType, | 150 | filePath, rootDestinationFolder, foldersCreated, nodesLoaded); |
145 | rootDestinationFolder, foldersCreated, nodesLoaded); | ||
146 | 151 | ||
147 | if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) | 152 | if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) |
148 | { | 153 | { |
@@ -184,7 +189,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
184 | /// Replicate the inventory paths in the archive to the user's inventory as necessary. | 189 | /// Replicate the inventory paths in the archive to the user's inventory as necessary. |
185 | /// </summary> | 190 | /// </summary> |
186 | /// <param name="archivePath">The item archive path to replicate</param> | 191 | /// <param name="archivePath">The item archive path to replicate</param> |
187 | /// <param name="isDir">Is the path we're dealing with a directory?</param> | ||
188 | /// <param name="rootDestinationFolder">The root folder for the inventory load</param> | 192 | /// <param name="rootDestinationFolder">The root folder for the inventory load</param> |
189 | /// <param name="foldersCreated"> | 193 | /// <param name="foldersCreated"> |
190 | /// The folders created so far. This method will add more folders if necessary | 194 | /// The folders created so far. This method will add more folders if necessary |
@@ -196,17 +200,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
196 | /// <returns>The last user inventory folder created or found for the archive path</returns> | 200 | /// <returns>The last user inventory folder created or found for the archive path</returns> |
197 | public InventoryFolderBase ReplicateArchivePathToUserInventory( | 201 | public InventoryFolderBase ReplicateArchivePathToUserInventory( |
198 | string archivePath, | 202 | string archivePath, |
199 | bool isDir, | ||
200 | InventoryFolderBase rootDestFolder, | 203 | InventoryFolderBase rootDestFolder, |
201 | Dictionary <string, InventoryFolderBase> foldersCreated, | 204 | Dictionary <string, InventoryFolderBase> foldersCreated, |
202 | List<InventoryNodeBase> nodesLoaded) | 205 | List<InventoryNodeBase> nodesLoaded) |
203 | { | 206 | { |
204 | archivePath = archivePath.Substring(ArchiveConstants.INVENTORY_PATH.Length); | ||
205 | |||
206 | // Remove the file portion if we aren't already dealing with a directory path | ||
207 | if (!isDir) | ||
208 | archivePath = archivePath.Remove(archivePath.LastIndexOf("/") + 1); | ||
209 | |||
210 | string originalArchivePath = archivePath; | 207 | string originalArchivePath = archivePath; |
211 | 208 | ||
212 | // m_log.DebugFormat( | 209 | // m_log.DebugFormat( |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 507662f..cb6bf76 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -531,7 +531,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
531 | 531 | ||
532 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null) | 532 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null) |
533 | .ReplicateArchivePathToUserInventory( | 533 | .ReplicateArchivePathToUserInventory( |
534 | itemArchivePath, false, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | 534 | itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), |
535 | foldersCreated, nodesLoaded); | 535 | foldersCreated, nodesLoaded); |
536 | 536 | ||
537 | InventoryFolderBase folder1 | 537 | InventoryFolderBase folder1 |