Commit b415e061 authored by Juan Benet's avatar Juan Benet

Merge pull request #1797 from rht/fix/cat

Add context to coreunix.Cat argument
parents bb8e231b 6ae0973e
......@@ -67,7 +67,7 @@ func cat(ctx context.Context, node *core.IpfsNode, paths []string) ([]io.Reader,
readers := make([]io.Reader, 0, len(paths))
length := uint64(0)
for _, fpath := range paths {
read, err := coreunix.Cat(node, fpath)
read, err := coreunix.Cat(ctx, node, fpath)
if err != nil {
return nil, 0, err
}
......
package coreunix
import (
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
core "github.com/ipfs/go-ipfs/core"
path "github.com/ipfs/go-ipfs/path"
uio "github.com/ipfs/go-ipfs/unixfs/io"
)
func Cat(n *core.IpfsNode, pstr string) (*uio.DagReader, error) {
func Cat(ctx context.Context, n *core.IpfsNode, pstr string) (*uio.DagReader, error) {
p := path.FromString(pstr)
dagNode, err := n.Resolver.ResolvePath(n.Context(), p)
dagNode, err := n.Resolver.ResolvePath(ctx, p)
if err != nil {
return nil, err
}
return uio.NewDagReader(n.Context(), dagNode, n.DAG)
return uio.NewDagReader(ctx, dagNode, n.DAG)
}
......@@ -168,7 +168,7 @@ func TestIpfsStressRead(t *testing.T) {
t.Fatal(err)
}
read, err := coreunix.Cat(nd, item)
read, err := coreunix.Cat(nd.Context(), nd, item)
if err != nil {
t.Fatal(err)
}
......
......@@ -138,7 +138,7 @@ func DirectAddCat(data []byte, conf testutil.LatencyConfig) error {
return err
}
readerCatted, err := coreunix.Cat(catter, added)
readerCatted, err := coreunix.Cat(ctx, catter, added)
if err != nil {
return err
}
......
......@@ -84,7 +84,7 @@ func benchCat(b *testing.B, data []byte, conf testutil.LatencyConfig) error {
}
b.StartTimer()
readerCatted, err := coreunix.Cat(catter, added)
readerCatted, err := coreunix.Cat(ctx, catter, added)
if err != nil {
return err
}
......
......@@ -62,7 +62,7 @@ func RunSupernodeBootstrappedAddCat(data []byte, conf testutil.LatencyConfig) er
return err
}
readerCatted, err := coreunix.Cat(catter, keyAdded)
readerCatted, err := coreunix.Cat(ctx, catter, keyAdded)
if err != nil {
return err
}
......
......@@ -117,7 +117,7 @@ func RunThreeLeggedCat(data []byte, conf testutil.LatencyConfig) error {
return err
}
readerCatted, err := coreunix.Cat(catter, added)
readerCatted, err := coreunix.Cat(ctx, catter, added)
if err != nil {
return err
}
......
......@@ -199,7 +199,7 @@ func runFileCattingWorker(ctx context.Context, n *core.IpfsNode) error {
"localPeer": n.Identity,
}
}))
if r, err := coreunix.Cat(n, k); err != nil {
if r, err := coreunix.Cat(ctx, n, k); err != nil {
e.Done()
log.Printf("failed to cat file. seed: %d #%d key: %s err: %s", *seed, i, k, err)
} else {
......
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