win_copy - fix remote dir copy when it contains an empty dir (#50126)

This commit is contained in:
Jordan Borean
2018-12-19 14:55:09 +10:00
committed by GitHub
parent e9d7c8f328
commit 65ce1b727e
3 changed files with 63 additions and 4 deletions

View File

@@ -127,13 +127,13 @@ Function Copy-Folder($source, $dest) {
Function Get-FileSize($path) {
$file = Get-Item -Path $path -Force
$size = $null
if ($file.PSIsContainer) {
$dir_files_sum = Get-ChildItem $file.FullName -Recurse
if ($dir_files_sum -eq $null -or ($dir_files_sum.PSObject.Properties.name -contains 'length' -eq $false)) {
$size = (Get-ChildItem -Path $file.FullName -Recurse -Force | `
Where-Object { $_.PSObject.Properties.Name -contains 'Length' } | `
Measure-Object -Property Length -Sum).Sum
if ($null -eq $size) {
$size = 0
} else {
$size = ($dir_files_sum | Measure-Object -property length -sum).Sum
}
} else {
$size = $file.Length