"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
Add `b` suffix so we can specify bytes in --bwlimit, --min-size etc
Nick Craig-Wood5723d788a42a
diff --git a/docs/content/docs.md b/docs/content/docs.mdindex aeb6f3b66..a1c589740 100644--- a/docs/content/docs.md+++ b/docs/content/docs.md@@ -322,13 +322,14 @@ possibly signed sequence of decimal numbers, each with optionalfraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Validtime units are "ns", "us" (or "µs"), "ms", "s", "m", "h".-Options which use SIZE use kByte by default. However a suffix of `k`-for kBytes, `M` for MBytes and `G` for GBytes may be used. These are-the binary units, eg 2\*\*10, 2\*\*20, 2\*\*30 respectively.+Options which use SIZE use kByte by default. However a suffix of `b`+for bytes, `k` for kBytes, `M` for MBytes and `G` for GBytes may be+used. These are the binary units, eg 1, 2\*\*10, 2\*\*20, 2\*\*30+respectively.### --bwlimit=SIZE ###-Bandwidth limit in kBytes/s, or use suffix k|M|G. The default is `0`+Bandwidth limit in kBytes/s, or use suffix b|k|M|G. The default is `0`which means to not limit bandwidth.For example to limit bandwidth usage to 10 MBytes/s use `--bwlimit 10M`diff --git a/fs/config.go b/fs/config.goindex d7e7dd58f..98e89cea0 100644--- a/fs/config.go+++ b/fs/config.go@@ -94,7 +94,7 @@ var ()func init() {- pflag.VarP(&bwLimit, "bwlimit", "", "Bandwidth limit in kBytes/s, or use suffix k|M|G")+ pflag.VarP(&bwLimit, "bwlimit", "", "Bandwidth limit in kBytes/s, or use suffix b|k|M|G")}// Turn SizeSuffix into a string@@ -104,6 +104,9 @@ func (x SizeSuffix) String() string {switch {case x == 0:return "0"+ case x < 1024:+ scaled = float64(x)+ suffix = "b"case x < 1024*1024:scaled = float64(x) / 1024suffix = "k"@@ -132,6 +135,8 @@ func (x *SizeSuffix) Set(s string) error {case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.':suffixLen = 0multiplier = 1 << 10+ case 'b', 'B':+ multiplier = 1case 'k', 'K':multiplier = 1 << 10case 'm', 'M':diff --git a/fs/config_test.go b/fs/config_test.goindex 04849585c..e77b272de 100644--- a/fs/config_test.go+++ b/fs/config_test.go@@ -12,7 +12,7 @@ func TestSizeSuffixString(t *testing.T) {want string}{{0, "0"},- {102, "0.100k"},+ {102, "102b"},{1024, "1k"},{1024 * 1024, "1M"},{1024 * 1024 * 1024, "1G"},@@ -34,6 +34,8 @@ func TestSizeSuffixSet(t *testing.T) {err bool}{{"0", 0, false},+ {"1b", 1, false},+ {"102B", 102, false},{"0.1k", 102, false},{"0.1", 102, false},{"1K", 1024, false},diff --git a/fs/filter.go b/fs/filter.goindex 79578caa7..25f4db27f 100644--- a/fs/filter.go+++ b/fs/filter.go@@ -35,8 +35,8 @@ var ()func init() {- pflag.VarP(&minSize, "min-size", "", "Don't transfer any file smaller than this in k or suffix k|M|G")- pflag.VarP(&maxSize, "max-size", "", "Don't transfer any file larger than this in k or suffix k|M|G")+ pflag.VarP(&minSize, "min-size", "", "Don't transfer any file smaller than this in k or suffix b|k|M|G")+ pflag.VarP(&maxSize, "max-size", "", "Don't transfer any file larger than this in k or suffix b|k|M|G")}// rule is one filter rule