Hello community, here is the log from the commit of package rubygem-winrm-fs for openSUSE:Factory checked in at 2018-11-26 10:31:41 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-winrm-fs (Old) and /work/SRC/openSUSE:Factory/.rubygem-winrm-fs.new.19453 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-winrm-fs" Mon Nov 26 10:31:41 2018 rev:6 rq:651509 version:1.3.1 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-winrm-fs/rubygem-winrm-fs.changes 2018-09-11 17:18:46.699273859 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-winrm-fs.new.19453/rubygem-winrm-fs.changes 2018-11-26 10:33:01.848836420 +0100 @@ -1,0 +2,9 @@ +Thu Nov 22 05:41:29 UTC 2018 - Stephan Kulow <co...@suse.com> + +- updated to version 1.3.1 + see installed changelog.md + + # 1.3.1 + - Download files in chunks + +------------------------------------------------------------------- Old: ---- winrm-fs-1.3.0.gem New: ---- winrm-fs-1.3.1.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-winrm-fs.spec ++++++ --- /var/tmp/diff_new_pack.U8Lrlg/_old 2018-11-26 10:33:03.232834799 +0100 +++ /var/tmp/diff_new_pack.U8Lrlg/_new 2018-11-26 10:33:03.232834799 +0100 @@ -12,7 +12,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # @@ -24,7 +24,7 @@ # Name: rubygem-winrm-fs -Version: 1.3.0 +Version: 1.3.1 Release: 0 %define mod_name winrm-fs %define mod_full_name %{mod_name}-%{version} ++++++ winrm-fs-1.3.0.gem -> winrm-fs-1.3.1.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/VERSION new/VERSION --- old/VERSION 2018-09-01 06:10:06.000000000 +0200 +++ new/VERSION 2018-10-15 04:01:35.000000000 +0200 @@ -1 +1 @@ -1.3.0 +1.3.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/changelog.md new/changelog.md --- old/changelog.md 2018-09-01 06:10:06.000000000 +0200 +++ new/changelog.md 2018-10-15 04:01:35.000000000 +0200 @@ -1,4 +1,7 @@ # WinRM-fs Gem Changelog +# 1.3.1 +- Download files in chunks + # 1.3.0 - Upload from StringIO object - Add missing winrm/exceptions require in file_transporter Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/winrm-fs/core/file_transporter.rb new/lib/winrm-fs/core/file_transporter.rb --- old/lib/winrm-fs/core/file_transporter.rb 2018-09-01 06:10:06.000000000 +0200 +++ new/lib/winrm-fs/core/file_transporter.rb 2018-10-15 04:01:35.000000000 +0200 @@ -347,6 +347,7 @@ path = false locals.each do |local| raise UploadSourceError if string_io + if local.is_a?(StringIO) string_io = true else diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/winrm-fs/core/tmp_zip.rb new/lib/winrm-fs/core/tmp_zip.rb --- old/lib/winrm-fs/core/tmp_zip.rb 2018-09-01 06:10:06.000000000 +0200 +++ new/lib/winrm-fs/core/tmp_zip.rb 2018-10-15 04:01:35.000000000 +0200 @@ -103,6 +103,7 @@ def clean_dirname(dir) paths = Pathname.glob(dir) raise "Expected Pathname.glob(dir) to return only dir, got #{paths}" if paths.length != 1 + paths.first end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/winrm-fs/file_manager.rb new/lib/winrm-fs/file_manager.rb --- old/lib/winrm-fs/file_manager.rb 2018-09-01 06:10:06.000000000 +0200 +++ new/lib/winrm-fs/file_manager.rb 2018-10-15 04:01:35.000000000 +0200 @@ -59,16 +59,44 @@ # Downloads the specified remote file to the specified local path # @param [String] The full path on the remote machine # @param [String] The full path to write the file to locally - def download(remote_path, local_path, first = true) - @logger.debug("downloading: #{remote_path} -> #{local_path}") - script = WinRM::FS::Scripts.render('download', path: remote_path) - output = @connection.shell(:powershell) { |e| e.run(script) } - contents = output.stdout.gsub('\n\r', '') - return false if output.exitcode != 0 - download_dir(remote_path, local_path, first) if contents.empty? - IO.binwrite(local_path, Base64.decode64(contents)) unless contents.empty? + # rubocop:disable Metrics/MethodLength + def download(remote_path, local_path, chunk_size = 1024 * 1024, first = true) + @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? + 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 true end + # rubocop:enable Metrics/MethodLength + + def _output_from_file(remote_path, chunk_size, index) + script = WinRM::FS::Scripts.render('download', path: remote_path, chunk_size: chunk_size, index: index) + @connection.shell(:powershell) { |e| e.run(script) } + end + + def _write_file(tofd, output) + contents = output.stdout.gsub('\n\r', '') + out = Base64.decode64(contents) + out = out[0, out.length - 1] if out.end_with? "\x00" + return out if out.empty? + + tofd.write(out) + out + end # Checks to see if the given path exists on the target file system. # @param [String] The full path to the directory or file @@ -115,12 +143,12 @@ private - def download_dir(remote_path, local_path, first) + def download_dir(remote_path, local_path, chunk_size, first) local_path = File.join(local_path, File.basename(remote_path.to_s)) if first FileUtils.mkdir_p(local_path) unless File.directory?(local_path) command = "Get-ChildItem #{remote_path} | Select-Object Name" @connection.shell(:powershell) { |e| e.run(command) }.stdout.strip.split(/\n/).drop(2).each do |file| - download(File.join(remote_path.to_s, file.strip), File.join(local_path, file.strip), first = false) + download(File.join(remote_path.to_s, file.strip), File.join(local_path, file.strip), chunk_size, false) end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/winrm-fs/scripts/download.ps1.erb new/lib/winrm-fs/scripts/download.ps1.erb --- old/lib/winrm-fs/scripts/download.ps1.erb 2018-09-01 06:10:06.000000000 +0200 +++ new/lib/winrm-fs/scripts/download.ps1.erb 2018-10-15 04:01:35.000000000 +0200 @@ -1,11 +1,17 @@ $p = $ExecutionContext.SessionState.Path $path = $p.GetUnresolvedProviderPathFromPSPath("<%= path %>") -If (Test-Path $path -PathType Leaf) { - $bytes = [System.convert]::ToBase64String([System.IO.File]::ReadAllBytes($path)) +$index = <%= index %> +$chunkSize = <%= chunk_size %> +if (Test-Path $path -PathType Leaf) { + $file = [System.IO.File]::OpenRead($path) + $seekedTo = $file.Seek($index, [System.IO.SeekOrigin]::Begin) + $chunk = New-Object byte[] $chunkSize + $bytesRead = $file.Read($chunk, 0, $chunkSize) + $bytes = [System.convert]::ToBase64String($chunk[0..$bytesRead]) Write-Host $bytes exit 0 } ElseIf (Test-Path $path -PathType Container) { - exit 0 + exit 2 } exit 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2018-09-01 06:10:06.000000000 +0200 +++ new/metadata 2018-10-15 04:01:34.000000000 +0200 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: winrm-fs version: !ruby/object:Gem::Version - version: 1.3.0 + version: 1.3.1 platform: ruby authors: - Shawn Neal @@ -9,7 +9,7 @@ autorequire: bindir: bin cert_chain: [] -date: 2018-08-31 00:00:00.000000000 Z +date: 2018-10-14 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: erubis diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/integration/file_manager_spec.rb new/spec/integration/file_manager_spec.rb --- old/spec/integration/file_manager_spec.rb 2018-09-01 06:10:06.000000000 +0200 +++ new/spec/integration/file_manager_spec.rb 2018-10-15 04:01:35.000000000 +0200 @@ -58,6 +58,24 @@ end end + context 'download file chunked' do + let(:download_dir) { File.join(spec_dir, 'temp') } + let(:dest_file) { Pathname.new(File.join(dest_dir, File.basename(this_file))) } + let(:download_file) { Pathname.new(File.join(download_dir, File.basename(this_file))) } + + before(:each) do + expect(subject.delete(dest_dir)).to be true + FileUtils.rm_rf(Dir.glob("#{download_dir}/*")) + FileUtils.mkdir_p(download_dir) + end + + it 'should download the specified file in 1000 byte chunks' do + subject.upload(this_file, dest_file) + subject.download(dest_file, download_file, 1000) + expect(File.open(download_file).read).to eq(File.open(this_file).read) + end + end + context 'download directory' do let(:download_dir) { File.join(spec_dir, 'temp') } let(:dest_file) { Pathname.new(File.join(dest_dir, File.basename(this_file))) }