From ac9c20b04848ececf3fee156dc181bc27e01dd80 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 14 May 2016 17:11:19 +0100 Subject: [PATCH] Make IsRetryError function --- fs/error.go | 9 +++++++++ fs/operations.go | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/error.go b/fs/error.go index 66d32af18..97c9e2ee3 100644 --- a/fs/error.go +++ b/fs/error.go @@ -58,6 +58,15 @@ func RetryError(err error) error { return plainRetryError{err} } +// IsRetryError returns true if err conforms to the Retry interface +// and calling the Retry method returns true. +func IsRetryError(err error) bool { + if r, ok := err.(Retry); ok { + return r.Retry() + } + return false +} + // isClosedConnError reports whether err is an error from use of a closed // network connection. // diff --git a/fs/operations.go b/fs/operations.go index 8c9568766..6c4201204 100644 --- a/fs/operations.go +++ b/fs/operations.go @@ -238,7 +238,7 @@ tryAgain: inErr = in.Close() } // Retry if err returned a retry error - if r, ok := err.(Retry); ok && r.Retry() && tries < maxTries { + if IsRetryError(err) && tries < maxTries { tries++ Log(src, "Received error: %v - low level retry %d/%d", err, tries, maxTries) if removeFailedCopy(dst) {