1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Use passed blocks to handle scp callbacks.

This commit is contained in:
David Calavera 2013-03-12 16:54:46 +01:00
parent 8116689537
commit 6d469a9a61

View file

@ -66,11 +66,11 @@ module Fog
@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
@ -82,7 +82,7 @@ module Fog
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