Forum: Ruby Net/FTP: failed download creates empty file

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ronald Fischer (Guest)
on 2007-06-05 14:01
(Received via mailing list)
I'm downloading a file via FTP like this:

require 'net/ftp'
ftp=Net::FTP.new(hostname,userid,password)
begin
  ftp.getbinaryfile('fluffi')
rescue Net::FTPPermError
  puts "download #{filename} failed (#{$!.to_s.chomp})"
end

This works basically fine, with one minor glitch: If the file ('fluffi')
does not
exist (i.e. the exception is thrown - "download fluffi failed (550 Can't
open
fluffi: No such file or directory)"), there is still a file 'fluffi'
created
with length 0.

Is this a bug or intended behaviour?

Ronald
This topic is locked and can not be replied to.