class Turbotlib::FTPDelegator
Public Instance Methods
method_missing(m, *args, &block)
click to toggle source
echanges.dila.gouv.fr sometimes returns a local IP (192.168.30.9) for the host in `#makepasv`. We can store the first host received (which we assume to be good), and return it every time. However, even with a good IP, the next command times out. So, we instead retry the entire command with a new client, after closing the old client.
Calls superclass method
# File lib/turbotlib/ftp.rb, line 14 def method_missing(m, *args, &block) on_retry = Proc.new do |exception, try, elapsed_time, next_interval| @delegate_sd_obj.error("#{exception.message} on #{@delegate_sd_obj.last_cmd}") @delegate_sd_obj.close ftp = FTP.new(*@delegate_sd_obj.initialize_args) ftp.logger = @delegate_sd_obj.logger ftp.root_path = @delegate_sd_obj.root_path ftp.passive = true ftp.login dir = @delegate_sd_obj.last_dir.to_s unless dir.empty? ftp.chdir(dir) end __setobj__(ftp) end exception_classes = [Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::EHOSTUNREACH, Errno::ETIMEDOUT, EOFError] if Net.const_defined?(:ReadTimeout) # Ruby 2 exception_classes << Net::ReadTimeout end Retriable.retriable(on: exception_classes, on_retry: on_retry) do super end end