From a6191743b7413dee23e76d71fc6c6f89c17b728b Mon Sep 17 00:00:00 2001 From: Yuuzou Gotou Date: Thu, 14 Dec 2023 13:49:15 +0900 Subject: [PATCH] Removed inappropriate $! reference in Net::FTP Net::FTP#transfercmd uses $! for error handling, so using Net::FTP in the rescue section will cause an unexpected data connection drop. --- lib/net/ftp.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb index afb3349..d7b0bd3 100644 --- a/lib/net/ftp.rb +++ b/lib/net/ftp.rb @@ -577,8 +577,9 @@ def transfercmd(cmd, rest_offset = nil) # :nodoc: if !resp.start_with?("1") raise FTPReplyError, resp end - ensure - conn.close if conn && $! + rescue + conn&.close + raise end else sock = makeport