mirror of
https://github.com/rclone/rclone.git
synced 2024-11-25 09:41:44 +08:00
ftp: retry 426 errors
Before this change we didn't retry 426 errors which are 426 Connection closed; transfer aborted. Or in this particular case 426 Failure writing network stream. These seem like they might be temporary so retry them. See: https://forum.rclone.org/t/downloads-fail-from-remote-server-error-426-failure-writing-network-stream/33839/
This commit is contained in:
parent
62a7765e57
commit
2e435af4de
|
@ -315,18 +315,26 @@ func (dl *debugLog) Write(p []byte) (n int, err error) {
|
||||||
return len(p), nil
|
return len(p), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// returns true if this FTP error should be retried
|
||||||
|
func isRetriableFtpError(err error) bool {
|
||||||
|
switch errX := err.(type) {
|
||||||
|
case *textproto.Error:
|
||||||
|
switch errX.Code {
|
||||||
|
case ftp.StatusNotAvailable, ftp.StatusTransfertAborted:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// shouldRetry returns a boolean as to whether this err deserve to be
|
// shouldRetry returns a boolean as to whether this err deserve to be
|
||||||
// retried. It returns the err as a convenience
|
// retried. It returns the err as a convenience
|
||||||
func shouldRetry(ctx context.Context, err error) (bool, error) {
|
func shouldRetry(ctx context.Context, err error) (bool, error) {
|
||||||
if fserrors.ContextError(ctx, &err) {
|
if fserrors.ContextError(ctx, &err) {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
switch errX := err.(type) {
|
if isRetriableFtpError(err) {
|
||||||
case *textproto.Error:
|
return true, err
|
||||||
switch errX.Code {
|
|
||||||
case ftp.StatusNotAvailable:
|
|
||||||
return true, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return fserrors.ShouldRetry(err), err
|
return fserrors.ShouldRetry(err), err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user