Skip to content

Commit 37f6a1b

Browse files
committed
"repo stat": Make special value to represent NoLimit a constant.
License: MIT Signed-off-by: Kevin Atkinson <[email protected]>
1 parent f156f63 commit 37f6a1b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

core/commands/repo.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"fmt"
66
"io"
7-
"math"
87
"os"
98
"path/filepath"
109
"strings"
@@ -192,7 +191,7 @@ Version string The repo version.
192191
} else {
193192
fmt.Fprintf(wtr, "RepoSize:\t%d\n", stat.RepoSize)
194193
}
195-
if stat.StorageMax != math.MaxUint64 {
194+
if stat.StorageMax != corerepo.NoLimit {
196195
maxSizeInMiB := stat.StorageMax / (1024 * 1024)
197196
if human && maxSizeInMiB > 0 {
198197
fmt.Fprintf(wtr, "StorageMax (MiB):\t%d\n", maxSizeInMiB)

core/corerepo/stat.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ type Stat struct {
1919
StorageMax uint64 // size in bytes
2020
}
2121

22+
// NoLimit represents the value for unlimited storage
23+
const NoLimit uint64 = math.MaxUint64
24+
2225
func RepoStat(n *core.IpfsNode, ctx context.Context) (*Stat, error) {
2326
r := n.Repo
2427

@@ -47,7 +50,7 @@ func RepoStat(n *core.IpfsNode, ctx context.Context) (*Stat, error) {
4750
return nil, err
4851
}
4952

50-
var storageMax uint64 = math.MaxUint64
53+
storageMax := NoLimit
5154
if cfg.Datastore.StorageMax != "" {
5255
storageMax, err = humanize.ParseBytes(cfg.Datastore.StorageMax)
5356
if err != nil {

0 commit comments

Comments
 (0)