Skip to content

Commit

Permalink
Merge pull request #8 from rgernha/master
Browse files Browse the repository at this point in the history
Fixing Out-RsFolderContent and Write-RsFolderContent
  • Loading branch information
rgernha committed Nov 8, 2016
2 parents 8ffa7bf + 058f102 commit c46899c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
14 changes: 11 additions & 3 deletions Functions/CatalogItems/Out-RsFolderContent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ function Out-RsFolderContent
{
if(($item.TypeName -eq 'Folder') -and $Recurse)
{
$relativePath = Clear-Substring -string $item.Path -substring $Path -position front
$relativePath = $item.Path
if($Path -ne "/")
{
$relativePath = Clear-Substring -string $relativePath -substring $Path -position front
}
$relativePath = $relativePath.Replace("/", "\")

$newFolder = $Destination + $relativePath
Expand All @@ -88,8 +92,12 @@ function Out-RsFolderContent
$item.TypeName -eq "DataSet")
{
# We're relying on the fact that the implementation of Get-RsCatalogItems will show us the folder before their content,
# when using the -recurse option, so we can assume that any subfolder will be created before we download the items it contains
$relativePath = Clear-Substring -string $item.Path -substring $Path -position front
# when using the -recurse option, so we can assume that any subfolder will be created before we download the items it contains
$relativePath = $item.Path
if($Path -ne "/")
{
$relativePath = Clear-Substring -string $relativePath -substring $Path -position front
}
$relativePath = Clear-Substring -string $relativePath -substring ("/" + $item.Name) -position back
$relativePath = $relativePath.replace("/", "\")

Expand Down
12 changes: 9 additions & 3 deletions Functions/CatalogItems/Write-RsFolderContent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,16 @@ function Write-RsFolderContent()
$relativePath = Clear-Substring -string $item.FullName -substring $sourceFolder.FullName.TrimEnd("\") -position front
$relativePath = Clear-Substring -string $relativePath -substring ("\" + $item.Name) -position back
$relativePath = $relativePath.replace("\", "/")

$parentFolder = $DestinationFolder + $relativePath
if($DestinationFolder -eq "/" -and $relativePath -ne "")
{
$parentFolder = $relativePath
}
else
{
$parentFolder = $DestinationFolder + $relativePath
}

Write-Output "Creating folder $parentFolder/$($item.Name)"
Write-Verbose "Creating folder $parentFolder/$($item.Name)"
$Proxy.CreateFolder($item.Name, $parentFolder, $null) | Out-Null
}

Expand Down

0 comments on commit c46899c

Please sign in to comment.