diff options
author | Graham Barr <gbarr@pobox.com> | 2009-06-13 13:51:15 -0500 |
---|---|---|
committer | Graham Barr <gbarr@pobox.com> | 2009-06-13 13:51:15 -0500 |
commit | 4725dc2e7763cbabb3c532ed072e5cc58eb26bde (patch) | |
tree | 0af69d41a02c16606feca0051b2186fce3f54da2 | |
parent | c37154d1b5c996d12c62dd4ac641f676dc0b3c70 (diff) | |
download | perl-libnet-4725dc2e7763cbabb3c532ed072e5cc58eb26bde.tar.gz |
Ensure REST is sent directly before command being restarted
-rw-r--r-- | Net/FTP.pm | 34 |
1 files changed, 18 insertions, 16 deletions
@@ -21,7 +21,7 @@ use Net::Cmd; use Net::Config; use Fcntl qw(O_WRONLY O_RDONLY O_APPEND O_CREAT O_TRUNC); -$VERSION = '2.77_1'; +$VERSION = '2.77_2'; @ISA = qw(Exporter Net::Cmd IO::Socket::INET); # Someday I will "use constant", when I am not bothered to much about @@ -1015,22 +1015,24 @@ sub _data_cmd { { my $data = undef; - $ok = defined $ftp->pasv; - $ok = $ftp->_REST($where) - if $ok && $where; - - if ($ok) { - $ftp->command($cmd, @_); - $data = $ftp->_dataconn(); - $ok = CMD_INFO == $ftp->response(); - if ($ok) { - $data->reading - if $data && $cmd =~ /RETR|LIST|NLST/; - return $data; - } - $data->_close - if $data; + return undef unless defined $ftp->pasv; + $data = $ftp->_dataconn() or return undef; + + if ($where and !$ftp->_REST($where)) { + my ($status, $message) = ($ftp->status, $ftp->message); + $ftp->abort; + $ftp->set_status($status, $message); + return undef; + } + + $ftp->command($cmd, @_); + if (CMD_INFO == $ftp->response()) { + $data->reading + if $cmd =~ /RETR|LIST|NLST/; + return $data; } + $data->_close; + return undef; } |