Hello community, here is the log from the commit of package rubygem-winrm-fs for openSUSE:Factory checked in at 2018-09-11 17:18:43 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-winrm-fs (Old) and /work/SRC/openSUSE:Factory/.rubygem-winrm-fs.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-winrm-fs" Tue Sep 11 17:18:43 2018 rev:5 rq:634601 version:1.3.0 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-winrm-fs/rubygem-winrm-fs.changes 2018-03-06 10:46:35.549791522 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-winrm-fs.new/rubygem-winrm-fs.changes 2018-09-11 17:18:46.699273859 +0200 @@ -1,0 +2,14 @@ +Wed Sep 5 10:48:05 UTC 2018 - co...@suse.com + +- updated to version 1.3.0 + see installed changelog.md + + # 1.3.0 + - Upload from StringIO object + - Add missing winrm/exceptions require in file_transporter + - Use correct way to relativize paths of Zip entries + + # 1.2.1 + - Correctly handle unicode filenames + +------------------------------------------------------------------- Old: ---- winrm-fs-1.2.0.gem New: ---- winrm-fs-1.3.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-winrm-fs.spec ++++++ --- /var/tmp/diff_new_pack.L7Khwp/_old 2018-09-11 17:18:47.235273038 +0200 +++ /var/tmp/diff_new_pack.L7Khwp/_new 2018-09-11 17:18:47.239273032 +0200 @@ -24,12 +24,12 @@ # Name: rubygem-winrm-fs -Version: 1.2.0 +Version: 1.3.0 Release: 0 %define mod_name winrm-fs %define mod_full_name %{mod_name}-%{version} BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: %{ruby >= 2.1.0} +BuildRequires: %{ruby >= 2.2.0} BuildRequires: %{rubygem gem2rpm} BuildRequires: %{rubygem rdoc > 3.10} BuildRequires: ruby-macros >= 5 ++++++ winrm-fs-1.2.0.gem -> winrm-fs-1.3.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.rubocop.yml new/.rubocop.yml --- old/.rubocop.yml 2018-01-13 01:06:30.000000000 +0100 +++ new/.rubocop.yml 2018-09-01 06:10:06.000000000 +0200 @@ -7,6 +7,9 @@ Style/Encoding: Enabled: true +Layout/EndOfLine: + Enabled: false + Metrics/LineLength: Max: 120 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.rubocop_todo.yml new/.rubocop_todo.yml --- old/.rubocop_todo.yml 2018-01-13 01:06:30.000000000 +0100 +++ new/.rubocop_todo.yml 2018-09-01 06:10:06.000000000 +0200 @@ -34,13 +34,6 @@ - 'spec/matchers.rb' - 'winrm-fs.gemspec' -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: AutoCorrect. -Performance/HashEachMethods: - Exclude: - - 'lib/winrm-fs/core/file_transporter.rb' - # Offense count: 1 # Configuration parameters: . # SupportedStyles: annotated, template, unannotated diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.travis.yml new/.travis.yml --- old/.travis.yml 2018-01-13 01:06:30.000000000 +0100 +++ new/.travis.yml 2018-09-01 06:10:06.000000000 +0200 @@ -1,6 +1,6 @@ language: ruby rvm: - - 2.1.0 + - 2.2.0 - 2.3.4 - 2.4.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2018-01-13 01:06:30.000000000 +0100 +++ new/README.md 2018-09-01 06:10:06.000000000 +0200 @@ -4,7 +4,7 @@ [![Build status](https://ci.appveyor.com/api/projects/status/wm6apa8ojfhfmwsf?svg=true)](https://ci.appveyor.com/project/winrb/winrm-fs) ## Uploading files -Files may be copied from the local machine to the winrm endpoint. Individual files or directories, as well as arrays of files and directories may be specified: +Files may be copied from the local machine to the winrm endpoint. Individual files or directories, as well as arrays of files and directories may be specified. Data from a `StringIO` object may also be uploaded to a remote file. ```ruby require 'winrm-fs' @@ -17,6 +17,9 @@ # upload the my_dir directory to c:/foo/my_dir file_manager.upload('/Users/sneal/my_dir', 'c:/foo/my_dir') +# upload from an in-memory buffer +file_manager.upload(StringIO.new('some data to upload'), 'c:/file.txt') + # upload multiple directories and a file to c:\programData file_manager.upload([ '/Users/sneal/foo1', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Rakefile new/Rakefile --- old/Rakefile 2018-01-13 01:06:30.000000000 +0100 +++ new/Rakefile 2018-09-01 06:10:06.000000000 +0200 @@ -4,7 +4,7 @@ require 'rubocop/rake_task' # Change to the directory of this file. -Dir.chdir(File.expand_path('../', __FILE__)) +Dir.chdir(File.expand_path(__dir__)) # For gem creation and bundling require 'bundler/gem_tasks' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/VERSION new/VERSION --- old/VERSION 2018-01-13 01:06:30.000000000 +0100 +++ new/VERSION 2018-09-01 06:10:06.000000000 +0200 @@ -1 +1 @@ -1.2.0 +1.3.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/appveyor.yml new/appveyor.yml --- old/appveyor.yml 2018-01-13 01:06:30.000000000 +0100 +++ new/appveyor.yml 2018-09-01 06:10:06.000000000 +0200 @@ -9,7 +9,7 @@ winrm_password: Pass@word1 matrix: - - ruby_version: "21" + - ruby_version: "22" winrm_endpoint: http://localhost:5985/wsman clone_folder: c:\projects\winrm-fs diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/changelog.md new/changelog.md --- old/changelog.md 2018-01-13 01:06:30.000000000 +0100 +++ new/changelog.md 2018-09-01 06:10:06.000000000 +0200 @@ -1,4 +1,12 @@ # WinRM-fs Gem Changelog +# 1.3.0 +- Upload from StringIO object +- Add missing winrm/exceptions require in file_transporter +- Use correct way to relativize paths of Zip entries + +# 1.2.1 +- Correctly handle unicode filenames + # 1.2.0 - Add ability to download directories 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-01-13 01:06:30.000000000 +0100 +++ new/lib/winrm-fs/core/file_transporter.rb 2018-09-01 06:10:06.000000000 +0200 @@ -21,6 +21,7 @@ require 'securerandom' require 'stringio' +require 'winrm/exceptions' require 'winrm-fs/core/tmp_zip' module WinRM @@ -32,6 +33,14 @@ class FileTransporterFailed < ::WinRM::WinRMError; end # rubocop:disable MethodLength, AbcSize, ClassLength + # Exception for the case where upload source contains more than one + # StringIO object, or a combination of file/directory paths and StringIO object + class UploadSourceError < StandardError + def initialize(msg = 'Only a single StringIO object may be uploaded.') + super + end + end + # Object which can upload one or more files or directories to a remote # host over WinRM using PowerShell scripts and CMD commands. Note that # this form of file transfer is *not* ideal and extremely costly on both @@ -56,6 +65,7 @@ @shell = shell @logger = shell.logger @id_generator = opts.fetch(:id_generator) { -> { SecureRandom.uuid } } + Zip.unicode_names = true end # Uploads a collection of files and/or directories to the remote host. @@ -66,17 +76,16 @@ # * progress yields block like net-scp progress # * final API: def upload(locals, remote, _options = {}, &_progress) # - # @param locals [Array<String>,String] one or more local file or - # directory paths + # @param locals [Array<String>,String,StringIO] one or more + # local file or directory paths, StringIO objects also accepted # @param remote [String] the base destination path on the remote host # @return [Hash] report hash, keyed by the local SHA1 digest def upload(locals, remote) files = nil report = nil remote = remote.to_s - elapsed1 = Benchmark.measure do - files = make_files_hash(Array(locals), remote) + files = make_files_hash([locals].flatten, remote) report = check_files(files) merge_with_report!(files, report) reconcile_destinations!(files) @@ -182,16 +191,15 @@ # Adds an entry to a files Hash (keyed by local SHA1 digest) for a file. # # @param hash [Hash] hash to be mutated - # @param local [String] file path + # @param local [String, StringIO] file path or StringIO object # @param remote [String] path to destination on remote host # @api private def add_file_hash!(hash, local, remote) logger.debug "creating hash for file #{remote}" - hash[sha1sum(local)] = { 'src' => local, 'dst' => remote, - 'size' => File.size(local) + 'size' => local.is_a?(StringIO) ? local.size : File.size(local) } end @@ -222,7 +230,7 @@ sha1, { 'target' => data.fetch('tmpzip', data['dst']), - 'src_basename' => File.basename(data['src']), + 'src_basename' => data['src'].is_a?(StringIO) ? data['dst'] : File.basename(data['src']), 'dst' => data['dst'] } ] @@ -301,33 +309,61 @@ # digest. Each file entry has a source and destination set, at a # minimum. # - # @param locals [Array<String>] a collection of local files or - # directories + # @param locals [Array<String,StringIO>] a collection of local files, + # directories or StringIO objects # @param remote [String] the base destination path on the remote host # @return [Hash] files hash, keyed by the local SHA1 digest # @api private def make_files_hash(locals, remote) hash = {} + check_locals_array(locals) locals.each do |local| - local = local.to_s - expanded = File.expand_path(local) - expanded += local[-1] if local.end_with?('/', '\\') - - if File.file?(expanded) - add_file_hash!(hash, expanded, remote) - elsif File.directory?(expanded) - add_directory_hash!(hash, expanded, remote) + if local.is_a?(StringIO) + add_file_hash!(hash, local, remote) else - raise Errno::ENOENT, "No such file or directory #{expanded}" + local = local.to_s + expanded = File.expand_path(local) + expanded += local[-1] if local.end_with?('/', '\\') + if File.file?(expanded) + add_file_hash!(hash, expanded, remote) + elsif File.directory?(expanded) + add_directory_hash!(hash, expanded, remote) + else + raise Errno::ENOENT, "No such file or directory #{expanded}" + end end end hash end - # @return [String] the SHA1 digest of a local file + # Ensure that only a single StringIO object is uploaded at a time + # This is necessary because the contents of the buffer will be written + # to the destination. + # @param locals [Array<String,StringIO>] a collection of local files, + # directories or StringIO objects + # @api private + def check_locals_array(locals) + string_io = false + path = false + locals.each do |local| + raise UploadSourceError if string_io + if local.is_a?(StringIO) + string_io = true + else + path = true + end + raise UploadSourceError if string_io && path + end + end + + # @return [String] the SHA1 digest of a local file or StringIO # @api private def sha1sum(local) - Digest::SHA1.file(local).hexdigest + if local.is_a?(StringIO) + Digest::SHA1.hexdigest(local.string) + else + Digest::SHA1.file(local).hexdigest + end end # Destructively merges a report Hash into an existing files Hash. @@ -432,7 +468,7 @@ # ClearScriptBlockCache to clear it. $bindingFlags= [Reflection.BindingFlags] "NonPublic,Static" $method = [scriptblock].GetMethod("ClearScriptBlockCache", $bindingFlags) - EOS + EOS ) while input_io.read(read_size, buffer) @@ -458,7 +494,7 @@ # Uploads a local file. # - # @param src [String] path to a local file + # @param src [String, StringIO] path to a local file or StringIO object # @param dest [String] path to the file on the remote host # @return [Integer,Integer] the number of resulting upload chunks and # the number of bytes transferred to the remote host @@ -468,8 +504,12 @@ chunks = 0 bytes = 0 elapsed = Benchmark.measure do - File.open(src, 'rb') do |io| - chunks, bytes = stream_upload(io, dest, &block) + if src.is_a?(StringIO) + chunks, bytes = stream_upload(src, dest, &block) + else + File.open(src, 'rb') do |io| + chunks, bytes = stream_upload(io, dest, &block) + end end end logger.debug( 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-01-13 01:06:30.000000000 +0100 +++ new/lib/winrm-fs/core/tmp_zip.rb 2018-09-01 06:10:06.000000000 +0200 @@ -125,7 +125,7 @@ # @api private def produce_zip_entries(zos) entries.each do |entry| - entry_path = entry.sub(/#{dir}\//i, '') + entry_path = entry.relative_path_from(dir) logger.debug "+++ Adding #{entry_path}" zos.put_next_entry( zip_entry(entry_path), 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-01-13 01:06:30.000000000 +0100 +++ new/lib/winrm-fs/file_manager.rb 2018-09-01 06:10:06.000000000 +0200 @@ -83,7 +83,7 @@ # 'C:/Windows/Temp' # @return [String] Full path to the temp directory def temp_dir - @guest_temp ||= begin + @temp_dir ||= begin (@connection.shell(:powershell) { |e| e.run('$env:TEMP') }).stdout.chomp.tr('\\', '/') end end @@ -116,7 +116,7 @@ private def download_dir(remote_path, local_path, first) - local_path = File.join(local_path, File.basename(remote_path)) if 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| diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2018-01-13 01:06:30.000000000 +0100 +++ new/metadata 2018-09-01 06:10:06.000000000 +0200 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: winrm-fs version: !ruby/object:Gem::Version - version: 1.2.0 + version: 1.3.0 platform: ruby authors: - Shawn Neal @@ -9,7 +9,7 @@ autorequire: bindir: bin cert_chain: [] -date: 2018-01-12 00:00:00.000000000 Z +date: 2018-08-31 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: erubis @@ -189,7 +189,7 @@ requirements: - - ">=" - !ruby/object:Gem::Version - version: 2.1.0 + version: 2.2.0 required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" @@ -197,7 +197,7 @@ version: '0' requirements: [] rubyforge_project: -rubygems_version: 2.6.11 +rubygems_version: 2.7.6 signing_key: specification_version: 4 summary: WinRM File System 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-01-13 01:06:30.000000000 +0100 +++ new/spec/integration/file_manager_spec.rb 2018-09-01 06:10:06.000000000 +0200 @@ -86,11 +86,27 @@ context 'upload file' do let(:dest_file) { Pathname.new(File.join(dest_dir, File.basename(this_file))) } + let(:from_memory) { StringIO.new('Upload From Memory') } before(:each) do expect(subject.delete(dest_dir)).to be true end + it 'should upload a single StringIO object to a remote file' do + subject.upload(from_memory, dest_file) + expect(subject).to have_created(dest_file).with_content(from_memory.string) + end + + it 'should error if multiple StringIO objects passed to upload' do + expect { subject.upload([from_memory, from_memory], dest_file) } + .to raise_error(WinRM::FS::Core::UploadSourceError) + end + + it 'should error if both a StringIO object and a file path passed to upload' do + expect { subject.upload([from_memory, this_file], dest_file) } + .to raise_error(WinRM::FS::Core::UploadSourceError) + end + it 'should upload the specified file' do subject.upload(this_file, dest_file) expect(subject).to have_created(dest_file).with_content(this_file) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/spec_helper.rb new/spec/spec_helper.rb --- old/spec/spec_helper.rb 2018-01-13 01:06:30.000000000 +0100 +++ new/spec/spec_helper.rb 2018-09-01 06:10:06.000000000 +0200 @@ -9,7 +9,6 @@ def winrm_connection WinRM::Connection.new(config) end - # rubocop:enable AbcSize def config @config ||= begin diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/winrm-fs.gemspec new/winrm-fs.gemspec --- old/winrm-fs.gemspec 2018-01-13 01:06:30.000000000 +0100 +++ new/winrm-fs.gemspec 2018-09-01 06:10:06.000000000 +0200 @@ -1,30 +1,30 @@ require 'date' -version = File.read(File.expand_path('../VERSION', __FILE__)).strip +version = File.read(File.expand_path('VERSION', __dir__)).strip Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = 'winrm-fs' s.version = version - s.date = Date.today.to_s + s.date = Date.today.to_s s.author = ['Shawn Neal', 'Matt Wrock'] s.email = ['sn...@sneal.net', 'm...@mattwrock.com'] s.homepage = 'http://github.com/WinRb/winrm-fs' s.summary = 'WinRM File System' - s.description = <<-EOF + s.description = <<-EOF Ruby library for file system operations via Windows Remote Management EOF s.files = `git ls-files`.split(/\n/) s.require_path = 'lib' - s.rdoc_options = %w[-x test/ -x examples/] + s.rdoc_options = %w[-x test/ -x examples/] s.extra_rdoc_files = %w[README.md LICENSE] s.bindir = 'bin' s.executables = ['rwinrmcp'] - s.required_ruby_version = '>= 2.1.0' + s.required_ruby_version = '>= 2.2.0' s.add_runtime_dependency 'erubis', '~> 2.7' s.add_runtime_dependency 'logging', ['>= 1.6.1', '< 3.0'] s.add_runtime_dependency 'rubyzip', '~> 1.1'