forked from TrueCloudLab/rclone
ftp: fix errors from Close of a stream which hasn't been fully read
This commit is contained in:
parent
412dacf8be
commit
e172f00e0e
1 changed files with 7 additions and 2 deletions
|
@ -1,8 +1,6 @@
|
||||||
// Package ftp interfaces with FTP servers
|
// Package ftp interfaces with FTP servers
|
||||||
package ftp
|
package ftp
|
||||||
|
|
||||||
// FIXME Mover and DirMover are possible using c.Rename
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"net/textproto"
|
"net/textproto"
|
||||||
|
@ -568,6 +566,13 @@ type ftpReadCloser struct {
|
||||||
// Close the FTP reader and return the connection to the pool
|
// Close the FTP reader and return the connection to the pool
|
||||||
func (f *ftpReadCloser) Close() error {
|
func (f *ftpReadCloser) Close() error {
|
||||||
err := f.ReadCloser.Close()
|
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)
|
f.f.putFtpConnection(&f.c)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue