Albirew/nyaa-pantsu
Albirew
/
nyaa-pantsu
Archivé
1
0
Bifurcation 0

Fix filesize formatting edge cases

1024 bytes should be "1.0 KiB" not "1024.0 B"
Cette révision appartient à :
sfan5 2017-05-07 21:06:20 +02:00
Parent ac33a734fd
révision a17813f01b
1 fichiers modifiés avec 4 ajouts et 4 suppressions

Voir le fichier

@ -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 {