lib/net/sftp/operations/abstract.rb in net-sftp-0.5.0 vs lib/net/sftp/operations/abstract.rb in net-sftp-0.9.0
- old
+ new
@@ -47,25 +47,30 @@
# be performed synchronously, with the expected value being returned.
def execute( *args, &callback )
@log.debug "executing" if @log.debug?
unless block_given?
+ status = result = nil
callback = Proc.new do |status, *pargs|
- @session.status = status
- case
- when pargs.empty? then return @session.status
- when pargs.length == 1 then return pargs.first
- else return pargs
+ status = status
+ result = case
+ when pargs.empty? then @session.status
+ when pargs.length == 1 then pargs.first
+ else pargs
end
end
end
@callback = callback
@id = perform *args
@log.debug "received request id #{@id}"
@session.register( @id, self )
- @session.loop unless block_given?
+ unless block_given?
+ @session.loop { status.nil? }
+ @session.status = status
+ return result
+ end
end
# A callback for SFTP status packets. By default, raises an exception unless
# the status is FX_OK, in which case the registered callback is invoked.
def do_status( code, message, language )