From 7d70eb034664c2f5b5ca33ce5728e46248069c88 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 28 Feb 2020 11:40:24 +0000 Subject: [PATCH] ftp: attempt to work-around pureftp sending spurious 150 messages pureftpd has a bug where it sends messages like this ``` 150-Accepted data connection\r\n Response code: File status okay; about to open data connection (150) Response arg: Accepted data connection 150 32768.0 kbytes to download\r\n 150 0.014 seconds (measured here), 1665.27 Mbytes per second\r\n ``` The last `150` is treated as a new response - the previous `150` should have been `150-`. This means that rclone sees the `150 0.014 seconds (measured here), 1665.27 Mbytes per second` as a reply to the next message and reports it as an error. This fix ignores that specific message when it is received in the `Close` method. It dumps the FTP connection after as it is out of sync. See: #3984 Fixes #3445 --- backend/ftp/ftp.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/ftp/ftp.go b/backend/ftp/ftp.go index f96e66a65..c44c01134 100644 --- a/backend/ftp/ftp.go +++ b/backend/ftp/ftp.go @@ -799,10 +799,12 @@ func (f *ftpReadCloser) Close() error { f.f.putFtpConnection(&f.c, nil) } // mask the error if it was caused by a premature close + // NB StatusAboutToSend is to work around a bug in pureftpd + // See: https://github.com/rclone/rclone/issues/3445#issuecomment-521654257 switch errX := err.(type) { case *textproto.Error: switch errX.Code { - case ftp.StatusTransfertAborted, ftp.StatusFileUnavailable: + case ftp.StatusTransfertAborted, ftp.StatusFileUnavailable, ftp.StatusAboutToSend: err = nil } }