refactor: do pathname trimming outside of ReplicateArchivePathToUserInventory()

soprefactor
Justin Clark-Casey (justincc) 2010-06-04 23:34:42 +01:00
parent 72bd68a21f
commit 3c3df9f3e9
2 changed files with 8 additions and 11 deletions

View File

@ -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.
/// </summary>
/// <param name="archivePath">The item archive path to replicate</param>
/// <param name="isDir">Is the path we're dealing with a directory?</param>
/// <param name="rootDestinationFolder">The root folder for the inventory load</param>
/// <param name="foldersCreated">
/// The folders created so far. This method will add more folders if necessary
@ -196,17 +200,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
/// <returns>The last user inventory folder created or found for the archive path</returns>
public InventoryFolderBase ReplicateArchivePathToUserInventory(
string archivePath,
bool isDir,
InventoryFolderBase rootDestFolder,
Dictionary <string, InventoryFolderBase> foldersCreated,
List<InventoryNodeBase> 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(

View File

@ -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