mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
win_copy - fix remote dir copy when it contains an empty dir (#50126)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user