From 606961f49d34c58cebbe8ba68b4fea9c3cc28ae2 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 4 Jul 2016 13:16:05 +0100 Subject: [PATCH] b2: Treat 403 errors (eg cap exceeded) as fatal #420 --- b2/api/types.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/b2/api/types.go b/b2/api/types.go index abe907440..e7da9e8ee 100644 --- a/b2/api/types.go +++ b/b2/api/types.go @@ -4,6 +4,8 @@ import ( "fmt" "strconv" "time" + + "github.com/ncw/rclone/fs" ) // Error describes a B2 error response @@ -18,6 +20,15 @@ func (e *Error) Error() string { return fmt.Sprintf("%s (%d %s)", e.Message, e.Status, e.Code) } +// Fatal statisfies the Fatal interface +// +// It indicates which errors should be treated as fatal +func (e *Error) Fatal() bool { + return e.Status == 403 // 403 errors shouldn't be retried +} + +var _ fs.Fataler = (*Error)(nil) + // Account describes a B2 account type Account struct { ID string `json:"accountId"` // The identifier for the account.