SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
util: trim minFreeSpace values before parsing (#10083)
patrick3e2c637858ad
diff --git a/weed/util/minfreespace.go b/weed/util/minfreespace.goindex d069813384..044cfc2652 100644--- a/weed/util/minfreespace.go+++ b/weed/util/minfreespace.go@@ -87,6 +87,7 @@ var ErrMinFreeSpaceBadValue = errors.New("minFreeSpace is invalid")// ParseMinFreeSpace parses min free space expression s as percentage like 1,10 or human readable size like 10Gfunc ParseMinFreeSpace(s string) (*MinFreeSpace, error) {+ s = strings.TrimSpace(s)if percent, e := strconv.ParseFloat(s, 32); e == nil {if percent < 0 || percent > 100 {return nil, ErrMinFreeSpaceBadValuediff --git a/weed/util/minfreespace_test.go b/weed/util/minfreespace_test.goindex eec1942ddb..496a50b563 100644--- a/weed/util/minfreespace_test.go+++ b/weed/util/minfreespace_test.go@@ -15,6 +15,8 @@ func TestParseMinFreeSpace(t *testing.T) {{in: "100Ki", ok: true, value: &MinFreeSpace{Type: AsBytes, Bytes: 100 * 1024, Raw: "100Ki"}},{in: "100GiB", ok: true, value: &MinFreeSpace{Type: AsBytes, Bytes: 100 * 1024 * 1024 * 1024, Raw: "100GiB"}},{in: "42M", ok: true, value: &MinFreeSpace{Type: AsBytes, Bytes: 42 * 1000 * 1000, Raw: "42M"}},+ {in: " 42 ", ok: true, value: &MinFreeSpace{Type: AsPercent, Percent: 42, Raw: "42"}},+ {in: " 42M ", ok: true, value: &MinFreeSpace{Type: AsBytes, Bytes: 42 * 1000 * 1000, Raw: "42M"}},}for _, p := range tests {