From 6ae0973e1fc4f437e3cf9e942682146673ed54d9 Mon Sep 17 00:00:00 2001 From: rht Date: Sun, 4 Oct 2015 23:10:43 +0700 Subject: [PATCH] Add context to coreunix.Cat argument License: MIT Signed-off-by: rht --- core/commands/cat.go | 2 +- core/coreunix/cat.go | 7 ++++--- fuse/readonly/ipfs_test.go | 2 +- test/integration/addcat_test.go | 2 +- test/integration/bench_cat_test.go | 2 +- test/integration/grandcentral_test.go | 2 +- test/integration/three_legged_cat_test.go | 2 +- test/supernode_client/main.go | 2 +- 8 files changed, 11 insertions(+), 10 deletions(-) diff --git a/core/commands/cat.go b/core/commands/cat.go index 810dcb6d8..d48d11a13 100644 --- a/core/commands/cat.go +++ b/core/commands/cat.go @@ -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 } diff --git a/core/coreunix/cat.go b/core/coreunix/cat.go index 9904635fb..1138bf68a 100644 --- a/core/coreunix/cat.go +++ b/core/coreunix/cat.go @@ -1,16 +1,17 @@ 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) } diff --git a/fuse/readonly/ipfs_test.go b/fuse/readonly/ipfs_test.go index c6cb12151..7add4deb3 100644 --- a/fuse/readonly/ipfs_test.go +++ b/fuse/readonly/ipfs_test.go @@ -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) } diff --git a/test/integration/addcat_test.go b/test/integration/addcat_test.go index c5b021837..f00da35da 100644 --- a/test/integration/addcat_test.go +++ b/test/integration/addcat_test.go @@ -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 } diff --git a/test/integration/bench_cat_test.go b/test/integration/bench_cat_test.go index c3853860b..7237a78ea 100644 --- a/test/integration/bench_cat_test.go +++ b/test/integration/bench_cat_test.go @@ -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 } diff --git a/test/integration/grandcentral_test.go b/test/integration/grandcentral_test.go index e2e53c11e..877062307 100644 --- a/test/integration/grandcentral_test.go +++ b/test/integration/grandcentral_test.go @@ -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 } diff --git a/test/integration/three_legged_cat_test.go b/test/integration/three_legged_cat_test.go index 9d9cc146c..278e3d1e4 100644 --- a/test/integration/three_legged_cat_test.go +++ b/test/integration/three_legged_cat_test.go @@ -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 } diff --git a/test/supernode_client/main.go b/test/supernode_client/main.go index a9f8dec92..0cacc95e2 100644 --- a/test/supernode_client/main.go +++ b/test/supernode_client/main.go @@ -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 {