Commit 061a8663 authored by Jeromy's avatar Jeromy

ensure dagreaders are cleaned up after 'cat' command finishes

parent 69333e47
......@@ -8,6 +8,7 @@ import (
path "github.com/jbenet/go-ipfs/path"
uio "github.com/jbenet/go-ipfs/unixfs/io"
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/cheggaaa/pb"
)
......@@ -32,9 +33,7 @@ it contains.
return
}
readers := make([]io.Reader, 0, len(req.Arguments()))
readers, length, err := cat(node, req.Arguments())
readers, length, err := cat(req.Context().Context, node, req.Arguments())
if err != nil {
res.SetError(err, cmds.ErrNormal)
return
......@@ -59,7 +58,7 @@ it contains.
},
}
func cat(node *core.IpfsNode, paths []string) ([]io.Reader, uint64, error) {
func cat(ctx context.Context, node *core.IpfsNode, paths []string) ([]io.Reader, uint64, error) {
readers := make([]io.Reader, 0, len(paths))
length := uint64(0)
for _, fpath := range paths {
......@@ -68,7 +67,7 @@ func cat(node *core.IpfsNode, paths []string) ([]io.Reader, uint64, error) {
return nil, 0, err
}
read, err := uio.NewDagReader(node.Context(), dagnode, node.DAG)
read, err := uio.NewDagReader(ctx, dagnode, node.DAG)
if err != nil {
return nil, 0, err
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment