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
1d59331b
Commit
1d59331b
authored
Mar 23, 2017
by
Jeromy Johnson
Committed by
GitHub
Mar 23, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3820 from ipfs/kevina/filestore-util-fix
filestore util: Use a Marshaler instead of PostRun...
parents
c5bb2e9f
ffe9f3e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
38 deletions
+36
-38
core/commands/filestore.go
core/commands/filestore.go
+36
-38
No files found.
core/commands/filestore.go
View file @
1d59331b
...
...
@@ -3,6 +3,7 @@ package commands
import
(
"context"
"fmt"
"io"
cmds
"github.com/ipfs/go-ipfs/commands"
"github.com/ipfs/go-ipfs/core"
...
...
@@ -61,29 +62,27 @@ The output is:
res
.
SetOutput
(
out
)
}
},
PostRun
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
if
res
.
Error
()
!=
nil
{
return
}
outChan
,
ok
:=
res
.
Output
()
.
(
<-
chan
interface
{})
if
!
ok
{
res
.
SetError
(
u
.
ErrCast
(),
cmds
.
ErrNormal
)
return
}
res
.
SetOutput
(
nil
)
errors
:=
false
for
r0
:=
range
outChan
{
r
:=
r0
.
(
*
filestore
.
ListRes
)
if
r
.
ErrorMsg
!=
""
{
errors
=
true
fmt
.
Fprintf
(
res
.
Stderr
(),
"%s
\n
"
,
r
.
ErrorMsg
)
}
else
{
fmt
.
Fprintf
(
res
.
Stdout
(),
"%s
\n
"
,
r
.
FormatLong
())
Marshalers
:
cmds
.
MarshalerMap
{
cmds
.
Text
:
func
(
res
cmds
.
Response
)
(
io
.
Reader
,
error
)
{
outChan
,
ok
:=
res
.
Output
()
.
(
<-
chan
interface
{})
if
!
ok
{
return
nil
,
u
.
ErrCast
()
}
}
if
errors
{
res
.
SetError
(
fmt
.
Errorf
(
"errors while displaying some entries"
),
cmds
.
ErrNormal
)
}
errors
:=
false
for
r0
:=
range
outChan
{
r
:=
r0
.
(
*
filestore
.
ListRes
)
if
r
.
ErrorMsg
!=
""
{
errors
=
true
fmt
.
Fprintf
(
res
.
Stderr
(),
"%s
\n
"
,
r
.
ErrorMsg
)
}
else
{
fmt
.
Fprintf
(
res
.
Stdout
(),
"%s
\n
"
,
r
.
FormatLong
())
}
}
if
errors
{
return
nil
,
fmt
.
Errorf
(
"errors while displaying some entries"
)
}
return
nil
,
nil
},
},
Type
:
filestore
.
ListRes
{},
}
...
...
@@ -137,23 +136,22 @@ For ERROR entries the error will also be printed to stderr.
res
.
SetOutput
(
out
)
}
},
PostRun
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
if
res
.
Error
()
!=
nil
{
return
}
outChan
,
ok
:=
res
.
Output
()
.
(
<-
chan
interface
{})
if
!
ok
{
res
.
SetError
(
u
.
ErrCast
(),
cmds
.
ErrNormal
)
return
}
res
.
SetOutput
(
nil
)
for
r0
:=
range
outChan
{
r
:=
r0
.
(
*
filestore
.
ListRes
)
if
r
.
Status
==
filestore
.
StatusOtherError
{
fmt
.
Fprintf
(
res
.
Stderr
(),
"%s
\n
"
,
r
.
ErrorMsg
)
Marshalers
:
cmds
.
MarshalerMap
{
cmds
.
Text
:
func
(
res
cmds
.
Response
)
(
io
.
Reader
,
error
)
{
outChan
,
ok
:=
res
.
Output
()
.
(
<-
chan
interface
{})
if
!
ok
{
return
nil
,
u
.
ErrCast
()
}
fmt
.
Fprintf
(
res
.
Stdout
(),
"%s %s
\n
"
,
r
.
Status
.
Format
(),
r
.
FormatLong
())
}
res
.
SetOutput
(
nil
)
for
r0
:=
range
outChan
{
r
:=
r0
.
(
*
filestore
.
ListRes
)
if
r
.
Status
==
filestore
.
StatusOtherError
{
fmt
.
Fprintf
(
res
.
Stderr
(),
"%s
\n
"
,
r
.
ErrorMsg
)
}
fmt
.
Fprintf
(
res
.
Stdout
(),
"%s %s
\n
"
,
r
.
Status
.
Format
(),
r
.
FormatLong
())
}
return
nil
,
nil
},
},
Type
:
filestore
.
ListRes
{},
}
...
...
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