Lower threshold for "unlimited".

Seems like some kernels report a value a bit lower than MaxInt64.

Fixes #796
This commit is contained in:
Victor Marmol 2015-07-06 18:26:31 -07:00
parent ec240b60c5
commit 03059960e2

View File

@ -18,7 +18,6 @@ package pages
import (
"fmt"
"html/template"
"math"
"net/http"
"net/url"
"path"
@ -149,15 +148,19 @@ func toMegabytes(bytes uint64) float64 {
return float64(bytes) / (1 << 20)
}
// Size after which we consider memory to be "unlimited". This is not
// MaxInt64 due to rounding by the kernel.
const maxMemorySize = uint64(1 << 62)
func printSize(bytes uint64) string {
if bytes >= math.MaxInt64 {
if bytes >= maxMemorySize {
return "unlimited"
}
return ByteSize(bytes).Size()
}
func printUnit(bytes uint64) string {
if bytes >= math.MaxInt64 {
if bytes >= maxMemorySize {
return ""
}
return ByteSize(bytes).Unit()