From 65a25a2848ac6bdeaebeb15b18577a87c321fdcb Mon Sep 17 00:00:00 2001 From: SunRunAway Date: Wed, 10 Jul 2013 18:18:32 +0800 Subject: [PATCH] do ReadCodeLine in Close() @ ReadCloser --- client_test.go | 7 +++++++ ftp.go | 14 +++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/client_test.go b/client_test.go index 0291bdc..2745c65 100644 --- a/client_test.go +++ b/client_test.go @@ -57,6 +57,13 @@ func TestConn(t *testing.T) { r.Close() } + r, err = c.Retr("tset") + if err != nil { + t.Error(err) + } else { + r.Close() + } + err = c.Delete("tset") if err != nil { t.Error(err) diff --git a/ftp.go b/ftp.go index 90c92ed..e4d63c1 100644 --- a/ftp.go +++ b/ftp.go @@ -405,16 +405,16 @@ func (c *ServerConn) Quit() error { // Read implements the io.Reader interface on a FTP data connection. func (r *response) Read(buf []byte) (int, error) { n, err := r.conn.Read(buf) - if err == io.EOF { - _, _, err2 := r.c.conn.ReadCodeLine(StatusClosingDataConnection) - if err2 != nil { - err = err2 - } - } return n, err } // Close implements the io.Closer interface on a FTP data connection. func (r *response) Close() error { - return r.conn.Close() + err := r.conn.Close() + _, _, err2 := r.c.conn.ReadCodeLine(StatusClosingDataConnection) + if err2 != nil { + err = err2 + } + return err } +