0
@@ -134,29 +134,53 @@ module Capistrano
0
- def prepare_sftp_transfer(from, to, session)
0
- # FIXME: connect! is a synchronous operation, do this async and then synchronize all at once
0
- sftp = Net::SFTP::Session.new(session).connect!
0
- real_callback = Proc.new do |event, op, *args|
0
- callback.call(event, op, *args)
0
- logger.trace "[#{op[:host]}] #{args[0].remote}"
0
- elsif event == :finish
0
- logger.trace "[#{op[:host]}] done"
0
+ class SFTPTransferWrapper
0
+ attr_reader :operation
0
+ def initialize(session, &callback)
0
+ Net::SFTP::Session.new(session) do |sftp|
0
+ @operation = callback.call(sftp)
0
- op[:channel].close if event == :finish
0
- opts[:properties] = (opts[:properties] || {}).merge(
0
- :server => session.xserver,
0
- :host => session.xserver.host,
0
- :channel => sftp.channel)
0
+ @operation.nil? || @operation.active?
0
+ @operation[key] = value
0
- operation = case direction
0
+ def prepare_sftp_transfer(from, to, session)
0
+ SFTPTransferWrapper.new(session) do |sftp|
0
+ real_callback = Proc.new do |event, op, *args|
0
+ callback.call(event, op, *args)
0
+ logger.trace "[#{op[:host]}] #{args[0].remote}"
0
+ elsif event == :finish
0
+ logger.trace "[#{op[:host]}] done"
0
+ op[:channel].close if event == :finish
0
+ opts[:properties] = (opts[:properties] || {}).merge(
0
+ :server => session.xserver,
0
+ :host => session.xserver.host,
0
+ :channel => sftp.channel)
0
sftp.upload(from, to, opts, &real_callback)
0
@@ -164,8 +188,7 @@ module Capistrano
0
raise ArgumentError, "unsupported transfer direction: #{direction.inspect}"
0
def normalize(argument, session)
Comments
No one has commented yet.