From a17813f01b931996f8e65c3a55b4ed42ba17a60c Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sun, 7 May 2017 21:06:20 +0200 Subject: [PATCH] Fix filesize formatting edge cases 1024 bytes should be "1.0 KiB" not "1024.0 B" --- util/format.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/format.go b/util/format.go index 44eb12ca..38466f69 100644 --- a/util/format.go +++ b/util/format.go @@ -7,16 +7,16 @@ import ( func FormatFilesize(bytes int64) string { var unit string var value float64 - if bytes > 1024*1024*1024*1024 { + if bytes >= 1024*1024*1024*1024 { unit = "TiB" value = float64(bytes) / (1024*1024*1024*1024) - } else if bytes > 1024*1024*1024 { + } else if bytes >= 1024*1024*1024 { unit = "GiB" value = float64(bytes) / (1024*1024*1024) - } else if bytes > 1024*1024 { + } else if bytes >= 1024*1024 { unit = "MiB" value = float64(bytes) / (1024*1024) - } else if bytes > 1024 { + } else if bytes >= 1024 { unit = "KiB" value = float64(bytes) / (1024) } else {