1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-15 15:53:41 +00:00

Add b suffix so we can specify bytes in --bwlimit, --min-size etc

Fixes #449
This commit is contained in:
Nick Craig-Wood
2016-06-03 21:16:48 +01:00
parent 1d6698a754
commit 5723d788a4
4 changed files with 16 additions and 8 deletions

View File

@@ -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) / 1024
suffix = "k"
@@ -132,6 +135,8 @@ func (x *SizeSuffix) Set(s string) error {
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.':
suffixLen = 0
multiplier = 1 << 10
case 'b', 'B':
multiplier = 1
case 'k', 'K':
multiplier = 1 << 10
case 'm', 'M':