Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
ee33606a
Unverified
Commit
ee33606a
authored
Mar 20, 2019
by
Steven Allen
Committed by
GitHub
Mar 20, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6106 from reinerRubin/fix/cmds/6103-repo-stat-human-flag
Command repo stat: improve human flag behavior
parents
69492ca1
5e40ee19
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
core/commands/repo.go
core/commands/repo.go
+7
-6
No files found.
core/commands/repo.go
View file @
ee33606a
...
...
@@ -12,6 +12,7 @@ import (
"sync"
"text/tabwriter"
humanize
"github.com/dustin/go-humanize"
cmdenv
"github.com/ipfs/go-ipfs/core/commands/cmdenv"
corerepo
"github.com/ipfs/go-ipfs/core/corerepo"
fsrepo
"github.com/ipfs/go-ipfs/repo/fsrepo"
...
...
@@ -148,7 +149,7 @@ Version string The repo version.
},
Options
:
[]
cmdkit
.
Option
{
cmdkit
.
BoolOption
(
repoSizeOnlyOptionName
,
"Only report RepoSize and StorageMax."
),
cmdkit
.
BoolOption
(
repoHumanOptionName
,
"
Outpu
t sizes in
MiB.
"
),
cmdkit
.
BoolOption
(
repoHumanOptionName
,
"
Prin
t sizes in
human readable format (e.g., 1K 234M 2G)
"
),
},
Run
:
func
(
req
*
cmds
.
Request
,
res
cmds
.
ResponseEmitter
,
env
cmds
.
Environment
)
error
{
n
,
err
:=
cmdenv
.
GetNode
(
env
)
...
...
@@ -185,12 +186,12 @@ Version string The repo version.
sizeOnly
,
_
:=
req
.
Options
[
repoSizeOnlyOptionName
]
.
(
bool
)
printSize
:=
func
(
name
string
,
size
uint64
)
{
sizeInMiB
:=
size
/
(
1024
*
1024
)
if
human
&&
sizeInMiB
>
0
{
fmt
.
Fprintf
(
wtr
,
"%s (MiB):
\t
%d
\n
"
,
name
,
sizeInMiB
)
}
else
{
fmt
.
Fprintf
(
wtr
,
"%s:
\t
%d
\n
"
,
name
,
size
)
sizeStr
:=
fmt
.
Sprintf
(
"%d"
,
size
)
if
human
{
sizeStr
=
humanize
.
Bytes
(
size
)
}
fmt
.
Fprintf
(
wtr
,
"%s:
\t
%s
\n
"
,
name
,
sizeStr
)
}
if
!
sizeOnly
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment