1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Update winrm to allow fetch_file to work on files in use by processes (#18174)

This commit is contained in:
Ssawa 2017-02-09 19:43:52 -05:00 committed by Matt Davis
parent 39aaa32e40
commit 149dd9ca86

View file

@ -426,7 +426,7 @@ class Connection(ConnectionBase):
script = ''' script = '''
If (Test-Path -PathType Leaf "%(path)s") If (Test-Path -PathType Leaf "%(path)s")
{ {
$stream = [System.IO.File]::OpenRead("%(path)s"); $stream = New-Object IO.FileStream("%(path)s", [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read, [IO.FileShare]::ReadWrite);
$stream.Seek(%(offset)d, [System.IO.SeekOrigin]::Begin) | Out-Null; $stream.Seek(%(offset)d, [System.IO.SeekOrigin]::Begin) | Out-Null;
$buffer = New-Object Byte[] %(buffer_size)d; $buffer = New-Object Byte[] %(buffer_size)d;
$bytesRead = $stream.Read($buffer, 0, %(buffer_size)d); $bytesRead = $stream.Read($buffer, 0, %(buffer_size)d);