"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
b2: Fix handling of token expiry #420
Nick Craig-Woodcbebefebc49c
diff --git a/b2/b2.go b/b2/b2.goindex b4457c42c..ffd41e086 100644--- a/b2/b2.go+++ b/b2/b2.go@@ -44,13 +44,10 @@ const (// Globalsvar (- minChunkSize = fs.SizeSuffix(100E6)- chunkSize = fs.SizeSuffix(96 * 1024 * 1024)- uploadCutoff = fs.SizeSuffix(200E6)- errorAuthTokenExpired = errors.New("b2 auth token expired")- errorUploadTokenExpired = errors.New("b2 upload token expired")- errorUploadPartTokenExpired = errors.New("b2 upload part token expired")- b2TestMode = pflag.StringP("b2-test-mode", "", "", "A flag string for X-Bz-Test-Mode header.")+ minChunkSize = fs.SizeSuffix(100E6)+ chunkSize = fs.SizeSuffix(96 * 1024 * 1024)+ uploadCutoff = fs.SizeSuffix(200E6)+ b2TestMode = pflag.StringP("b2-test-mode", "", "", "A flag string for X-Bz-Test-Mode header."))// Register with Fs@@ -161,9 +158,8 @@ func (f *Fs) shouldRetryNoReauth(resp *http.Response, err error) (bool, error) {// shouldRetry returns a boolean as to whether this resp and err// deserve to be retried. It returns the err as a conveniencefunc (f *Fs) shouldRetry(resp *http.Response, err error) (bool, error) {- if err == nil && resp != nil && resp.StatusCode == 401 {- err = errorAuthTokenExpired- fs.Debug(f, "%v", err)+ if resp != nil && resp.StatusCode == 401 {+ fs.Debug(f, "Unauthorized: %v", err)// ReauthauthErr := f.authorizeAccount()if authErr != nil {@@ -1198,9 +1194,8 @@ func (o *Object) Update(in io.Reader, src fs.ObjectInfo) (err error) {// Don't retry, return a retry error insteaderr = o.fs.pacer.CallNoRetry(func() (bool, error) {resp, err := o.fs.srv.CallJSON(&opts, nil, &response)- if err == nil && resp != nil && resp.StatusCode == 401 {- err = errorUploadTokenExpired- fs.Debug(o, "%v", err)+ if resp != nil && resp.StatusCode == 401 {+ fs.Debug(o, "Unauthorized: %v", err)// Invalidate this Upload URLupload = nil// Refetch upload URLsdiff --git a/b2/upload.go b/b2/upload.goindex e961590b4..9802b0831 100644--- a/b2/upload.go+++ b/b2/upload.go@@ -178,9 +178,8 @@ func (up *largeUpload) transferChunk(part int64, body []byte) error {var response api.UploadPartResponseresp, err := up.f.srv.CallJSON(&opts, nil, &response)- if err == nil && resp != nil && resp.StatusCode == 401 {- err = errorUploadPartTokenExpired- fs.Debug(up.o, "%v", err)+ if resp != nil && resp.StatusCode == 401 {+ fs.Debug(up.o, "Unauthorized: %v", err)// Refetch upload part URLs and ditch this current oneup.clearUploadURL()return true, err