62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/evil-winrm.rb', line 62
def download(remote_path, local_path, chunk_size = 1024 * 1024, first = true, size: -1)
@logger.debug("downloading: #{remote_path} -> #{local_path} #{chunk_size}")
index = 0
output = _output_from_file(remote_path, chunk_size, index)
return download_dir(remote_path, local_path, chunk_size, first) if output.exitcode == 2
return false if output.exitcode >= 1
File.open(local_path, 'wb') do |fd|
out = _write_file(fd, output)
index += out.length
until out.empty?
if size != -1
yield index, size
end
output = _output_from_file(remote_path, chunk_size, index)
return false if output.exitcode >= 1
out = _write_file(fd, output)
index += out.length
end
end
end
|