diff options
| author | bingoohuang <bingoo.huang@gmail.com> | 2021-04-27 10:37:24 +0800 |
|---|---|---|
| committer | bingoohuang <bingoo.huang@gmail.com> | 2021-04-27 10:37:24 +0800 |
| commit | cf552417a7a422d1313c53972fd1175684e758e0 (patch) | |
| tree | 621d6f4f432cefe75c455939e084193eb7462001 /weed/util/bytes.go | |
| parent | 31f1cdeac281fb88a3d03743f9796f81e1d74378 (diff) | |
| download | seaweedfs-cf552417a7a422d1313c53972fd1175684e758e0.tar.xz seaweedfs-cf552417a7a422d1313c53972fd1175684e758e0.zip | |
minFreeSpace refactored
Diffstat (limited to 'weed/util/bytes.go')
| -rw-r--r-- | weed/util/bytes.go | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/weed/util/bytes.go b/weed/util/bytes.go index 260e5067e..26da91033 100644 --- a/weed/util/bytes.go +++ b/weed/util/bytes.go @@ -5,7 +5,6 @@ import ( "crypto/md5" "crypto/rand" "encoding/base64" - "errors" "fmt" "io" "math" @@ -176,23 +175,12 @@ func EmptyTo(s, to string) string { return s } -var ErrMinFreeSpaceBadValue = errors.New("minFreeSpace is invalid") - -// ParseMinFreeSpace parses min free space expression s as percentage like 1,10 or human readable size like 10G -func ParseMinFreeSpace(s string) (float32, error) { - if value, e := strconv.ParseFloat(s, 32); e == nil { - if value < 0 || value > 100 { - return 0, ErrMinFreeSpaceBadValue - } - return float32(value), nil - } else if directSize, e2 := ParseBytes(s); e2 == nil { - if directSize <= 100 { - return 0, ErrMinFreeSpaceBadValue - } - return float32(directSize), nil +// IfElse works like b ? this : that. +func IfElse(b bool, this, that string) string { + if b { + return this } - - return 0, ErrMinFreeSpaceBadValue + return that } // ParseBytes parses a string representation of bytes into the number |
