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 ( import (
"fmt" "fmt"
"html/template" "html/template"
"math"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
@ -149,15 +148,19 @@ func toMegabytes(bytes uint64) float64 {
return float64(bytes) / (1 << 20) 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 { func printSize(bytes uint64) string {
if bytes >= math.MaxInt64 { if bytes >= maxMemorySize {
return "unlimited" return "unlimited"
} }
return ByteSize(bytes).Size() return ByteSize(bytes).Size()
} }
func printUnit(bytes uint64) string { func printUnit(bytes uint64) string {
if bytes >= math.MaxInt64 { if bytes >= maxMemorySize {
return "" return ""
} }
return ByteSize(bytes).Unit() return ByteSize(bytes).Unit()