"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
linkbox: retry bot protection HTML challenge responses instead of failing
Nick Craig-Woodd6190dc4f247
diff --git a/backend/linkbox/linkbox.go b/backend/linkbox/linkbox.goindex 311fd8c3d..04e481248 100644--- a/backend/linkbox/linkbox.go+++ b/backend/linkbox/linkbox.go@@ -15,6 +15,8 @@ import ("context""crypto/md5""crypto/tls"+ "encoding/json"+ "errors""fmt""io""net/http"@@ -256,11 +258,8 @@ func (f *Fs) login(ctx context.Context) error {// so this refreshes the token and updates the request parameters for// the retry.func (f *Fs) shouldRetryWeb(ctx context.Context, resp *http.Response, err error, result responser, opts *rest.Opts) (bool, error) {- if fserrors.ContextError(ctx, &err) {- return false, err- }- if fserrors.ShouldRetry(err) || fserrors.ShouldRetryHTTP(resp, retryErrorCodes) {- return true, err+ if retry, err := f.shouldRetry(ctx, resp, err); retry || err != nil {+ return retry, err}// If the web API returned an error, it may be due to an expired token.// Refresh the token and retry.@@ -1016,6 +1015,14 @@ func (f *Fs) shouldRetry(ctx context.Context, resp *http.Response, err error) (bif fserrors.ContextError(ctx, &err) {return false, err}+ // The API is fronted by bot protection which under load+ // intermittently returns an HTML challenge page with a 200+ // status instead of JSON. This surfaces as a JSON syntax error,+ // so retry it to let the pacer back off until the block lifts.+ var syntaxErr *json.SyntaxError+ if errors.As(err, &syntaxErr) {+ return true, err+ }return fserrors.ShouldRetry(err) || fserrors.ShouldRetryHTTP(resp, retryErrorCodes), err}