# upload to ftp server
ftp_filepath = nil
- ATTEMPTS.each do |attempt|
+ for attempt in ATTEMPTS
ftp_filepath = FileTransfer.putfile(ip, port, username, passwd, src_file, @log)
if !ftp_filepath.nil? then break;
else @log.info "Server is the #{attempt} upload attempt fails" end
if ftp_filepath.nil? then
req.puts "ERROR"
return false
- else @log.info "Server is the #{attempt} successful attempt to upload file: [#{File.basename(src_file)}]" end
+ else
+ @log.info "Server is the #{attempt} successful attempt to upload file: [#{File.basename(src_file)}]"
+ end
req.puts "UPLOADED,#{ftp_filepath}"
elsif cmd == "SUCC" then
@log.info "Client downloaded file successfully"
ftp_filepath = tok[1].strip
@log.info "Server uploaded file sucessfully"
dst_filepath = nil
- ATTEMPTS.each do |attempt|
+ for attempt in ATTEMPTS
dst_filepath = FileTransfer.getfile(ip, port, username, passwd, ftp_filepath, dst_file, @log)
if not dst_filepath.nil? then break
- else "Client is the #{attempt} download attempt fails" end
+ else
+ @log.warn "Client is the #{attempt} download attempt fails"
+ end
end
if dst_filepath.nil? then
send "ERROR"