From d817b60db0220aed715e4a561d87c9a74a889c2d Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Thu, 10 Apr 2008 07:48:58 -0600 Subject: [PATCH] make file uploads work via net-sftp v2 --- lib/capistrano/upload.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/capistrano/upload.rb b/lib/capistrano/upload.rb index bbb607a4..c647d0d4 100644 --- a/lib/capistrano/upload.rb +++ b/lib/capistrano/upload.rb @@ -56,11 +56,11 @@ module Capistrano def process! logger.debug "uploading #{filename}" if logger while running? - sessions.each do |session| + @uploaders.each do |uploader| begin - session.process(0) + uploader.sftp.session.process(0) rescue Net::SFTP::StatusException => error - logger.important "uploading failed: #{error.description}", session.xserver if logger + logger.important "uploading failed: #{error.description}", uploader[:server] if logger failed!(uploader) end end @@ -91,7 +91,10 @@ module Capistrano real_filename = filename.gsub(/\$CAPISTRANO:HOST\$/, server.host) logger.info "uploading data to #{server}:#{real_filename}" if logger - uploader = sftp.upload(StringIO.new(options[:data] || ""), real_filename, :permissions => options[:mode] || 0664) + + uploader = sftp.upload(StringIO.new(options[:data] || ""), real_filename, :permissions => options[:mode] || 0664) do |event, actor, *args| + completed!(actor) if event == :finish + end uploader[:server] = server uploader[:done] = false