Skip to content

Commit

Permalink
Build - Update WinSCP Core to 5.13.3. Bug fixes for #76, #78, and #79.…
Browse files Browse the repository at this point in the history
… Added new cmdlet Copy-WinSCPItem. Simplified path validation in Move-WinSCPItem.
  • Loading branch information
dotps1 committed Jun 21, 2018
1 parent dc78654 commit e3a3eef
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 63 deletions.
2 changes: 1 addition & 1 deletion WinSCP/Public/ConvertTo-WinSCPEscapedString.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
}
}
}

end {
$session.Dispose()
}
Expand Down
52 changes: 25 additions & 27 deletions WinSCP/Public/Copy-WinSCPItem.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,40 +47,38 @@ function Copy-WinSCPItem {
)

process {
process {
$Destination = Format-WinSCPPathString -Path $Destination
$destinationInfo = Get-WinSCPItem -WinSCPSession $WinSCPSession -Path $Destination -ErrorAction SilentlyContinue
$Destination = Format-WinSCPPathString -Path $Destination
$destinationInfo = Get-WinSCPItem -WinSCPSession $WinSCPSession -Path $Destination -ErrorAction SilentlyContinue

foreach ($pathValue in ( Format-WinSCPPathString -Path $Path )) {
try {
$shouldProcess = $PSCmdlet.ShouldProcess(
$pathValue
)
if ($shouldProcess) {
if ($null -ne $destinationInfo) {
$leaf = Split-Path -Path $pathValue -Leaf
$destinationPath = $WinSCPSession.CombinePaths(
$Destination, $leaf
)
}

if (( Test-WinSCPPath -WinSCPSession $WinSCPSession -Path $destinationPath ) -and $Force.IsPresent) {
Remove-WinSCPItem -WinSCPSession $WinSCPSession -Path $destinationPath -Confirm:$false
}

$WinSCPSession.DuplicateFile(
$pathValue, $destinationPath
foreach ($pathValue in ( Format-WinSCPPathString -Path $Path )) {
try {
$shouldProcess = $PSCmdlet.ShouldProcess(
$pathValue
)
if ($shouldProcess) {
if ($null -ne $destinationInfo) {
$leaf = Split-Path -Path $pathValue -Leaf
$destinationPath = $WinSCPSession.CombinePaths(
$Destination, $leaf
)
}

if ($PassThru.IsPresent) {
Get-WinSCPItem -WinSCPSession $WinSCPSession -Path $destinationPath
if (( Test-WinSCPPath -WinSCPSession $WinSCPSession -Path $destinationPath ) -and $Force.IsPresent) {
Remove-WinSCPItem -WinSCPSession $WinSCPSession -Path $destinationPath -Confirm:$false
}
} catch {
$PSCmdlet.WriteError(
$_

$WinSCPSession.DuplicateFile(
$pathValue, $destinationPath
)
}

if ($PassThru.IsPresent) {
Get-WinSCPItem -WinSCPSession $WinSCPSession -Path $destinationPath
}
} catch {
$PSCmdlet.WriteError(
$_
)
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions WinSCP/Public/Get-WinSCPChildItem.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
Mandatory = $true,
ValueFromPipelineByPropertyName = $true
)]
[ValidateScript({
if ($_.Opened) {
return $true
} else {
[ValidateScript({
if ($_.Opened) {
return $true
} else {
throw "The WinSCP Session is not in an Open state."
}
})]
Expand Down Expand Up @@ -78,7 +78,7 @@
)

$items = $items |
Sort-Object -Property IsDirectory -Descending:$false |
Sort-Object -Property IsDirectory -Descending:$false |
Sort-Object -Property @{ Expression = { Split-Path -Path $_.FullName } }, Name

if ($depthParameterUsed) {
Expand All @@ -104,11 +104,11 @@
} elseif ($File.IsPresent -and -not $Directory.IsPresent) {
$items = $items.Where({
$_.IsDirectory -eq $false
})
})
}

if ($Name.IsPresent) {
$items = $items |
$items = $items |
Select-Object -ExpandProperty Name
}

Expand Down
12 changes: 6 additions & 6 deletions WinSCP/Public/Get-WinSCPItem.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ function Get-WinSCPItem {
[OutputType(
[WinSCP.RemoteFileInfo]
)]

param (

[Parameter(
Mandatory = $true,
ValueFromPipelineByPropertyName = $true
)]
[ValidateScript({
if ($_.Opened) {
return $true
} else {
[ValidateScript({
if ($_.Opened) {
return $true
} else {
throw "The WinSCP Session is not in an Open state."
}
})]
Expand Down
10 changes: 5 additions & 5 deletions WinSCP/Public/Get-WinSCPItemChecksum.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
Mandatory = $true,
ValueFromPipelineByPropertyName = $true
)]
[ValidateScript({
if ($_.Opened) {
return $true
} else {
[ValidateScript({
if ($_.Opened) {
return $true
} else {
throw "The WinSCP Session is not in an Open state."
}
})]
Expand Down Expand Up @@ -54,5 +54,5 @@
)
}
}
}
}
}
2 changes: 1 addition & 1 deletion WinSCP/Public/Get-WinSCPSession.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function Get-WinSCPSession {

[CmdletBinding(
HelpUri = "https://github.com/dotps1/WinSCP/wiki/Get-WinSCPSession"
)]
Expand Down
10 changes: 5 additions & 5 deletions WinSCP/Public/Invoke-WinSCPCommand.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
Mandatory = $true,
ValueFromPipelineByPropertyName = $true
)]
[ValidateScript({
if ($_.Opened) {
return $true
} else {
[ValidateScript({
if ($_.Opened) {
return $true
} else {
throw "The WinSCP Session is not in an Open state."
}
})]
Expand Down Expand Up @@ -44,7 +44,7 @@
} catch {
$PSCmdlet.WriteError(
$_
)
)
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions WinSCP/Public/Send-WinSCPItem.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
Mandatory = $true,
ValueFromPipeline = $true
)]
[ValidateScript({
if ($_.Opened) {
return $true
} else {
[ValidateScript({
if ($_.Opened) {
return $true
} else {
throw "The WinSCP Session is not in an Open state."
}
})]
Expand All @@ -38,7 +38,7 @@
)]
[String]
$RemotePath = $WinSCPSession.HomePath,

[Parameter()]
[Switch]
$Remove,
Expand Down
10 changes: 5 additions & 5 deletions WinSCP/Public/Test-WinSCPPath.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
[OutputType(
[Bool]
)]

param (
[Parameter(
Mandatory = $true,
ValueFromPipeline = $true
)]
[ValidateScript({
if ($_.Opened) {
return $true
} else {
[ValidateScript({
if ($_.Opened) {
return $true
} else {
throw "The WinSCP Session is not in an Open state."
}
})]
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# http://www.appveyor.com/docs/appveyor-yml

version: 5.13.2.{build}
version: 5.13.3.{build}
os: WMF 5
branches:
only:
Expand Down

0 comments on commit e3a3eef

Please sign in to comment.