Skip to content

Commit

Permalink
v1.0.12 - bugfix in filetransfer. Create empty(0 byte) files as well
Browse files Browse the repository at this point in the history
  • Loading branch information
jarig committed Nov 18, 2015
1 parent f9881dc commit 586bc2a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/vagrant-vmm/scripts/sync_folders.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function Get-file-hash($source_paths, $delimiter) {
# get empty dirs, set hash to be 0 for them
Get-ChildItem $source_path_normalized -recurse |
Where-Object {$_.PSIsContainer -eq $True} |
Where-Object {$_.GetFiles().Count -eq 0} |
Where-Object {$_.GetFiles().Count -eq 0 -and $_.GetDirectories().Count -eq 0} |
Select-Object FullName | ForEach-Object -Process {
$source_files[$source_path] += $_.FullName.Replace($source_path_normalized, "") + $delimiter + "0"
}
Expand Down
36 changes: 26 additions & 10 deletions lib/vagrant-vmm/scripts/utils/send_file.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,38 @@ function Send-File
$position = 0

## Go through the input, and fill in the new array of file content
foreach ($chunk in $input)
{
[GC]::Collect()
[Array]::Copy($chunk, 0, $destBytes, $position, $chunk.Length)
$position += $chunk.Length
}

[IO.File]::WriteAllBytes($fileDest, $destBytes)
if ( $input )
{
foreach ($chunk in $input)
{
[GC]::Collect()
[Array]::Copy($chunk, 0, $destBytes, $position, $chunk.Length)
$position += $chunk.Length
}
}

if ( $position -eq 0 )
{
# create empty file
New-Item $fileDest -type file
} else
{
[IO.File]::WriteAllBytes($fileDest, $destBytes)
}

#Get-Item $fileDest
[GC]::Collect()
}
}

# Stream the chunks into the remote script.
$Length = $sourceBytes.Length
$streamChunks | Invoke-Command -Session $Session -ScriptBlock $remoteScript
if ( $Length -eq 0 )
{
$res = Invoke-Command -Session $Session -ScriptBlock $remoteScript
} else
{
$streamChunks | Invoke-Command -Session $Session -ScriptBlock $remoteScript
}
Write-Verbose -Message "WinRM copy of [$($p)] to [$($Destination)] complete"
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-vmm/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module VagrantPlugins
module VMM
VERSION = "1.0.11"
VERSION = "1.0.12"
end
end

0 comments on commit 586bc2a

Please sign in to comment.