提交 37f6a1bb 作者: Kevin Atkinson

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

License: MIT
Signed-off-by: 's avatarKevin Atkinson <k@kevina.org>
上级 f156f63e
...@@ -4,7 +4,6 @@ import ( ...@@ -4,7 +4,6 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"io" "io"
"math"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
...@@ -192,7 +191,7 @@ Version string The repo version. ...@@ -192,7 +191,7 @@ Version string The repo version.
} else { } else {
fmt.Fprintf(wtr, "RepoSize:\t%d\n", stat.RepoSize) fmt.Fprintf(wtr, "RepoSize:\t%d\n", stat.RepoSize)
} }
if stat.StorageMax != math.MaxUint64 { if stat.StorageMax != corerepo.NoLimit {
maxSizeInMiB := stat.StorageMax / (1024 * 1024) maxSizeInMiB := stat.StorageMax / (1024 * 1024)
if human && maxSizeInMiB > 0 { if human && maxSizeInMiB > 0 {
fmt.Fprintf(wtr, "StorageMax (MiB):\t%d\n", maxSizeInMiB) fmt.Fprintf(wtr, "StorageMax (MiB):\t%d\n", maxSizeInMiB)
......
...@@ -19,6 +19,9 @@ type Stat struct { ...@@ -19,6 +19,9 @@ type Stat struct {
StorageMax uint64 // size in bytes 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) { func RepoStat(n *core.IpfsNode, ctx context.Context) (*Stat, error) {
r := n.Repo r := n.Repo
...@@ -47,7 +50,7 @@ func RepoStat(n *core.IpfsNode, ctx context.Context) (*Stat, error) { ...@@ -47,7 +50,7 @@ func RepoStat(n *core.IpfsNode, ctx context.Context) (*Stat, error) {
return nil, err return nil, err
} }
var storageMax uint64 = math.MaxUint64 storageMax := NoLimit
if cfg.Datastore.StorageMax != "" { if cfg.Datastore.StorageMax != "" {
storageMax, err = humanize.ParseBytes(cfg.Datastore.StorageMax) storageMax, err = humanize.ParseBytes(cfg.Datastore.StorageMax)
if err != nil { if err != nil {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论