"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: implement --b2-test-mode to set `X-Bz-Test-Mode` header #420
Nick Craig-Wood6f3897ce2cbd
diff --git a/b2/b2.go b/b2/b2.goindex 801aa2492..b4457c42c 100644--- a/b2/b2.go+++ b/b2/b2.go@@ -39,6 +39,7 @@ const (maxSleep = 2 * time.SeconddecayConstant = 2 // bigger for slower decay, exponentialmaxParts = 10000+ testModeHeader = "X-Bz-Test-Mode")// Globals@@ -49,6 +50,7 @@ var (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."))// Register with Fs@@ -224,6 +226,12 @@ func NewFs(name, root string) (fs.Fs, error) {pacer: pacer.New().SetMinSleep(minSleep).SetMaxSleep(maxSleep).SetDecayConstant(decayConstant),uploadTokens: make(chan struct{}, fs.Config.Transfers),}+ // Set the test flag if required+ if *b2TestMode != "" {+ testMode := strings.TrimSpace(*b2TestMode)+ f.srv.SetHeader(testModeHeader, testMode)+ fs.Debug(f, "Setting test header \"%s: %s\"", testModeHeader, testMode)+ }// Fill up the upload tokensfor i := 0; i < fs.Config.Transfers; i++ {f.returnUploadToken()diff --git a/docs/content/b2.md b/docs/content/b2.mdindex 870712f1b..e08ac4898 100644--- a/docs/content/b2.md+++ b/docs/content/b2.md@@ -151,8 +151,17 @@ Cutoff for switching to chunked upload (default 4.657GiB ==`--b2-chunk-size`. The default value is the largest file which can beuploaded without chunks.-### API ###+#### --b2-test-mode=FLAG ####-Here are [some notes I made on the backblaze-API](https://gist.github.com/ncw/166dabf352b399f1cc1c) while-integrating it with rclone.+This is for debugging purposes only.++Setting FLAG to one of the strings below will cause b2 to return+specific errors for debugging purposes.++ * `fail_some_uploads`+ * `expire_some_account_authorization_tokens`+ * `force_cap_exceeded`++These will be set in the `X-Bz-Test-Mode` header which is documented+in the [b2 integrations+checklist](https://www.backblaze.com/b2/docs/integration_checklist.html).