Use IEC units for byte counting everywhere

This commit is contained in:
Nicola Murino 2021-02-12 22:16:35 +01:00
parent 6a6e8fffbc
commit 1ac66d27b6
No known key found for this signature in database
GPG key ID: 2F1FB59433D5A8CB
3 changed files with 6 additions and 6 deletions

View file

@ -267,7 +267,7 @@ func (t *ConnectionTransfer) getConnectionTransferAsString() string {
if t.Size > 0 { if t.Size > 0 {
elapsed := time.Since(utils.GetTimeFromMsecSinceEpoch(t.StartTime)) elapsed := time.Since(utils.GetTimeFromMsecSinceEpoch(t.StartTime))
speed := float64(t.Size) / float64(utils.GetTimeAsMsSinceEpoch(time.Now())-t.StartTime) speed := float64(t.Size) / float64(utils.GetTimeAsMsSinceEpoch(time.Now())-t.StartTime)
result += fmt.Sprintf("Size: %#v Elapsed: %#v Speed: \"%.1f KB/s\"", utils.ByteCountSI(t.Size), result += fmt.Sprintf("Size: %#v Elapsed: %#v Speed: \"%.1f KB/s\"", utils.ByteCountIEC(t.Size),
utils.GetDurationAsString(elapsed), speed) utils.GetDurationAsString(elapsed), speed)
} }
return result return result

View file

@ -706,9 +706,9 @@ func (u *User) GetQuotaSummary() string {
result += "/" + strconv.Itoa(u.QuotaFiles) result += "/" + strconv.Itoa(u.QuotaFiles)
} }
if u.UsedQuotaSize > 0 || u.QuotaSize > 0 { if u.UsedQuotaSize > 0 || u.QuotaSize > 0 {
result += ". Size: " + utils.ByteCountSI(u.UsedQuotaSize) result += ". Size: " + utils.ByteCountIEC(u.UsedQuotaSize)
if u.QuotaSize > 0 { if u.QuotaSize > 0 {
result += "/" + utils.ByteCountSI(u.QuotaSize) result += "/" + utils.ByteCountIEC(u.QuotaSize)
} }
} }
return result return result
@ -740,13 +740,13 @@ func (u *User) GetPermissionsAsString() string {
func (u *User) GetBandwidthAsString() string { func (u *User) GetBandwidthAsString() string {
result := "Download: " result := "Download: "
if u.DownloadBandwidth > 0 { if u.DownloadBandwidth > 0 {
result += utils.ByteCountSI(u.DownloadBandwidth*1000) + "/s." result += utils.ByteCountIEC(u.DownloadBandwidth*1000) + "/s."
} else { } else {
result += "unlimited." result += "unlimited."
} }
result += " Upload: " result += " Upload: "
if u.UploadBandwidth > 0 { if u.UploadBandwidth > 0 {
result += utils.ByteCountSI(u.UploadBandwidth*1000) + "/s." result += utils.ByteCountIEC(u.UploadBandwidth*1000) + "/s."
} else { } else {
result += "unlimited." result += "unlimited."
} }

View file

@ -49,7 +49,7 @@ func (v *BaseVirtualFolder) GetQuotaSummary() string {
var result string var result string
result = "Files: " + strconv.Itoa(v.UsedQuotaFiles) result = "Files: " + strconv.Itoa(v.UsedQuotaFiles)
if v.UsedQuotaSize > 0 { if v.UsedQuotaSize > 0 {
result += ". Size: " + utils.ByteCountSI(v.UsedQuotaSize) result += ". Size: " + utils.ByteCountIEC(v.UsedQuotaSize)
} }
if v.LastQuotaUpdate > 0 { if v.LastQuotaUpdate > 0 {
t := utils.GetTimeFromMsecSinceEpoch(v.LastQuotaUpdate) t := utils.GetTimeFromMsecSinceEpoch(v.LastQuotaUpdate)