common: fix size comparison in StorageSize (#33105)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run

This commit is contained in:
Rizky Ikwan 2025-11-06 02:25:41 +01:00 committed by GitHub
parent 395425902d
commit 15ff378a89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -26,13 +26,13 @@ type StorageSize float64
// String implements the stringer interface.
func (s StorageSize) String() string {
if s > 1099511627776 {
if s >= 1099511627776 {
return fmt.Sprintf("%.2f TiB", s/1099511627776)
} else if s > 1073741824 {
} else if s >= 1073741824 {
return fmt.Sprintf("%.2f GiB", s/1073741824)
} else if s > 1048576 {
} else if s >= 1048576 {
return fmt.Sprintf("%.2f MiB", s/1048576)
} else if s > 1024 {
} else if s >= 1024 {
return fmt.Sprintf("%.2f KiB", s/1024)
} else {
return fmt.Sprintf("%.2f B", s)
@ -42,13 +42,13 @@ func (s StorageSize) String() string {
// TerminalString implements log.TerminalStringer, formatting a string for console
// output during logging.
func (s StorageSize) TerminalString() string {
if s > 1099511627776 {
if s >= 1099511627776 {
return fmt.Sprintf("%.2fTiB", s/1099511627776)
} else if s > 1073741824 {
} else if s >= 1073741824 {
return fmt.Sprintf("%.2fGiB", s/1073741824)
} else if s > 1048576 {
} else if s >= 1048576 {
return fmt.Sprintf("%.2fMiB", s/1048576)
} else if s > 1024 {
} else if s >= 1024 {
return fmt.Sprintf("%.2fKiB", s/1024)
} else {
return fmt.Sprintf("%.2fB", s)