Skip to content

Commit

Permalink
Fix default options and updating key
Browse files Browse the repository at this point in the history
:password_prompt and :logger options are added in net-ssh
`Net::SSH.assign_defaults`.
Set default options early for ConnectionPool cache key.
The key in Cache object should be updated for comparing next time.
  • Loading branch information
shirosaki committed Mar 16, 2017
1 parent 264e980 commit 4edb96f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/sshkit/backends/connection_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def update_key_if_args_changed(cache, args)

caches.synchronize do
caches[new_key] = caches.delete(cache.key)
cache.key = new_key
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/sshkit/backends/connection_pool/cache.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# A Cache holds connections for a given key. Each connection is stored along
# with an expiration time so that its idle duration can be measured.
class SSHKit::Backend::ConnectionPool::Cache
attr_reader :key
attr_accessor :key

def initialize(key, idle_timeout, closer)
@key = key
Expand Down
8 changes: 8 additions & 0 deletions lib/sshkit/backends/netssh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,20 @@ def ssh_options
if Net::SSH::VALID_OPTIONS.include?(:known_hosts)
def default_options
@default_options ||= {known_hosts: SSHKit::Backend::Netssh::KnownHosts.new}
assign_defaults
end
else
def default_options
@default_options ||= {}
assign_defaults
end
end

# Set default options early for ConnectionPool cache key
def assign_defaults
Net::SSH.assign_defaults(@default_options)
@default_options
end
end

def upload!(local, remote, options = {})
Expand Down

0 comments on commit 4edb96f

Please sign in to comment.