From 3c3df9f3e9fbf9955c0939116e9bfeed1d429fa6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 4 Jun 2010 23:34:42 +0100 Subject: refactor: do pathname trimming outside of ReplicateArchivePathToUserInventory() --- .../Inventory/Archiver/InventoryArchiveReadRequest.cs | 17 +++++++---------- .../Inventory/Archiver/Tests/InventoryArchiverTests.cs | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region') 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 } else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) { + filePath = filePath.Substring(ArchiveConstants.INVENTORY_PATH.Length); + + // Trim off the file portion if we aren't already dealing with a directory path + if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) + filePath = filePath.Remove(filePath.LastIndexOf("/") + 1); + InventoryFolderBase foundFolder = ReplicateArchivePathToUserInventory( - filePath, TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType, - rootDestinationFolder, foldersCreated, nodesLoaded); + filePath, rootDestinationFolder, foldersCreated, nodesLoaded); if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) { @@ -184,7 +189,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// Replicate the inventory paths in the archive to the user's inventory as necessary. /// /// The item archive path to replicate - /// Is the path we're dealing with a directory? /// The root folder for the inventory load /// /// The folders created so far. This method will add more folders if necessary @@ -196,17 +200,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// The last user inventory folder created or found for the archive path public InventoryFolderBase ReplicateArchivePathToUserInventory( string archivePath, - bool isDir, InventoryFolderBase rootDestFolder, Dictionary foldersCreated, List nodesLoaded) { - archivePath = archivePath.Substring(ArchiveConstants.INVENTORY_PATH.Length); - - // Remove the file portion if we aren't already dealing with a directory path - if (!isDir) - archivePath = archivePath.Remove(archivePath.LastIndexOf("/") + 1); - string originalArchivePath = archivePath; // 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 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null) .ReplicateArchivePathToUserInventory( - itemArchivePath, false, scene.InventoryService.GetRootFolder(ua1.PrincipalID), + itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), foldersCreated, nodesLoaded); InventoryFolderBase folder1 -- cgit v1.1