From e172f00e0eb280fa0e2d81daa80d0ef22d62594a Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 19 May 2017 12:21:24 +0100 Subject: [PATCH] ftp: fix errors from Close of a stream which hasn't been fully read --- ftp/ftp.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ftp/ftp.go b/ftp/ftp.go index 97d1611ec..de70f64ee 100644 --- a/ftp/ftp.go +++ b/ftp/ftp.go @@ -1,8 +1,6 @@ // Package ftp interfaces with FTP servers package ftp -// FIXME Mover and DirMover are possible using c.Rename - import ( "io" "net/textproto" @@ -568,6 +566,13 @@ type ftpReadCloser struct { // Close the FTP reader and return the connection to the pool func (f *ftpReadCloser) Close() error { err := f.ReadCloser.Close() + switch errX := err.(type) { + case *textproto.Error: + switch errX.Code { + case ftp.StatusTransfertAborted, ftp.StatusFileUnavailable: + err = nil + } + } f.f.putFtpConnection(&f.c) return err }