Skip to content

Commit

Permalink
Don't drop error in readStreamedJson.
Browse files Browse the repository at this point in the history
Better fix than ipfs#3230 to make sure errors from addAllAndPin make it to
the client.

License: MIT
Signed-off-by: Kevin Atkinson <k@kevina.org>
  • Loading branch information
kevina committed Sep 30, 2016
1 parent dcb21bd commit 6ae4edc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions commands/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func getResponse(httpRes *http.Response, req cmds.Request) (cmds.Response, error
// if output is coming from a channel, decode each chunk
outChan := make(chan interface{})

go readStreamedJson(req, rr, outChan)
go readStreamedJson(req, rr, outChan, res)

res.SetOutput((<-chan interface{})(outChan))
return res, nil
Expand Down Expand Up @@ -233,7 +233,7 @@ func getResponse(httpRes *http.Response, req cmds.Request) (cmds.Response, error

// read json objects off of the given stream, and write the objects out to
// the 'out' channel
func readStreamedJson(req cmds.Request, rr io.Reader, out chan<- interface{}) {
func readStreamedJson(req cmds.Request, rr io.Reader, out chan<- interface{}, resp cmds.Response) {
defer close(out)
dec := json.NewDecoder(rr)
outputType := reflect.TypeOf(req.Command().Type)
Expand All @@ -245,6 +245,7 @@ func readStreamedJson(req cmds.Request, rr io.Reader, out chan<- interface{}) {
if err != nil {
if err != io.EOF {
log.Error(err)
resp.SetError(err, cmds.ErrNormal)
}
return
}
Expand Down

0 comments on commit 6ae4edc

Please sign in to comment.