Skip to content

Commit 29a6201

Browse files
committed
Fix for noisy load of ruby_smb gem
1 parent 339349b commit 29a6201

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

lib/bolt/transport/winrm/connection.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,20 @@ def upload_file_winrm(source, destination)
162162
raise Bolt::Node::FileError.new(e.message, 'WRITE_ERROR')
163163
end
164164

165-
def upload_file_smb(source, destination)
165+
def require_ruby_smb
166166
# lazy-load expensive gem code
167+
# In BinData 2.5.0+, the below commit makes things VERY noisy when loading RubySMB, so
168+
# we temporarily disable warnings while we load it. If this ever gets fixed, get rid
169+
# of this function and restore the plain 'require' where this function is called.
170+
# https://github.com/dmendel/bindata/commit/2c8588a1ae5959080fffa429e07027f2ff20161c
171+
prev = $VERBOSE
172+
$VERBOSE = nil
167173
require 'ruby_smb'
174+
$VERBOSE = prev
175+
end
176+
177+
def upload_file_smb(source, destination)
178+
require_ruby_smb
168179

169180
win_dest = destination.tr('/', '\\')
170181
if (md = win_dest.match(/^([a-z]):\\(.*)/i))
@@ -215,8 +226,7 @@ def download_file_winrm(source, destination, download)
215226
end
216227

217228
def download_file_smb(source, destination)
218-
# lazy-load expensive gem code
219-
require 'ruby_smb'
229+
require_ruby_smb
220230

221231
win_source = source.tr('/', '\\')
222232
if (md = win_source.match(/^([a-z]):\\(.*)/i))

spec/spec_helper.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212
require 'puppet_pal'
1313
# HACK: must be loaded prior to spec libs that implement stub to prevent
1414
# RubySMB::Dcerpc::Request from shadowing 'stub' through BinData::DSLMixin::DSLFieldValidator
15+
# In BinData 2.5.0+, the below commit makes things VERY noisy when loading RubySMB, so
16+
# we temporarily disable warnings while we load it.
17+
# https://github.com/dmendel/bindata/commit/2c8588a1ae5959080fffa429e07027f2ff20161c
18+
prev = $VERBOSE
19+
$VERBOSE = nil
1520
require 'ruby_smb'
21+
$VERBOSE = prev
1622

1723
ENV['RACK_ENV'] = 'test'
1824
$LOAD_PATH.unshift File.join(__dir__, 'lib')

0 commit comments

Comments
 (0)