Navigation Menu

Skip to content

Commit

Permalink
Use passed blocks to handle scp callbacks.
Browse files Browse the repository at this point in the history
  • Loading branch information
calavera committed Mar 12, 2013
1 parent 8116689 commit 6d469a9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/fog/core/scp.rb
Expand Up @@ -66,11 +66,11 @@ def initialize(address, username, options)
@options = { :paranoid => false }.merge(options)
end

def upload(local_path, remote_path, upload_options = {})
def upload(local_path, remote_path, upload_options = {}, &block)
begin
Net::SCP.start(@address, @username, @options) do |scp|
scp.upload!(local_path, remote_path, upload_options) do |ch, name, sent, total|
# TODO: handle progress display?
block.call(ch, name, sent, total) if block
end
end
rescue Exception => error
Expand All @@ -82,7 +82,7 @@ def download(remote_path, local_path, download_options = {})
begin
Net::SCP.start(@address, @username, @options) do |scp|
scp.download!(remote_path, local_path, download_options) do |ch, name, sent, total|
# TODO: handle progress display?
block.call(ch, name, sent, total) if block
end
end
rescue Exception => error
Expand Down

0 comments on commit 6d469a9

Please sign in to comment.