Commit 37f6a1bb authored by Kevin Atkinson's avatar Kevin Atkinson

"repo stat": Make special value to represent NoLimit a constant.

License: MIT
Signed-off-by: default avatarKevin Atkinson <k@kevina.org>
parent f156f63e
......@@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"io"
"math"
"os"
"path/filepath"
"strings"
......@@ -192,7 +191,7 @@ Version string The repo version.
} else {
fmt.Fprintf(wtr, "RepoSize:\t%d\n", stat.RepoSize)
}
if stat.StorageMax != math.MaxUint64 {
if stat.StorageMax != corerepo.NoLimit {
maxSizeInMiB := stat.StorageMax / (1024 * 1024)
if human && maxSizeInMiB > 0 {
fmt.Fprintf(wtr, "StorageMax (MiB):\t%d\n", maxSizeInMiB)
......
......@@ -19,6 +19,9 @@ type Stat struct {
StorageMax uint64 // size in bytes
}
// NoLimit represents the value for unlimited storage
const NoLimit uint64 = math.MaxUint64
func RepoStat(n *core.IpfsNode, ctx context.Context) (*Stat, error) {
r := n.Repo
......@@ -47,7 +50,7 @@ func RepoStat(n *core.IpfsNode, ctx context.Context) (*Stat, error) {
return nil, err
}
var storageMax uint64 = math.MaxUint64
storageMax := NoLimit
if cfg.Datastore.StorageMax != "" {
storageMax, err = humanize.ParseBytes(cfg.Datastore.StorageMax)
if err != nil {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment