Add context to coreunix.Cat argument
License: MIT Signed-off-by: rht <rhtbot@gmail.com>
rht committed
Oct 4, 2015 at 23:10 UTC
6ae0973e1fc4f437e3cf9e942682146673ed54d9
8 files changed
+11
-10
core/commands/cat.go
+1
-1
@@ -67,7 +67,7 @@ func cat(ctx context.Context, node *core.IpfsNode, paths []string) ([]io.Reader,
67
readers := make([]io.Reader, 0, len(paths))
68
length := uint64(0)
69
for _, fpath := range paths {
70
- read, err := coreunix.Cat(node, fpath)
70
+ read, err := coreunix.Cat(ctx, node, fpath)
71
if err != nil {
72
return nil, 0, err
73
}
core/coreunix/cat.go
+4
-3
@@ -1,16 +1,17 @@
1
package coreunix
2
3
import (
4
+ context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
5
core "github.com/ipfs/go-ipfs/core"
6
path "github.com/ipfs/go-ipfs/path"
7
uio "github.com/ipfs/go-ipfs/unixfs/io"
8
)
9
9
-func Cat(n *core.IpfsNode, pstr string) (*uio.DagReader, error) {
10
+func Cat(ctx context.Context, n *core.IpfsNode, pstr string) (*uio.DagReader, error) {
11
p := path.FromString(pstr)
11
- dagNode, err := n.Resolver.ResolvePath(n.Context(), p)
12
+ dagNode, err := n.Resolver.ResolvePath(ctx, p)
13
if err != nil {
14
return nil, err
15
}
15
- return uio.NewDagReader(n.Context(), dagNode, n.DAG)
16
+ return uio.NewDagReader(ctx, dagNode, n.DAG)
17
}
fuse/readonly/ipfs_test.go
+1
-1
@@ -168,7 +168,7 @@ func TestIpfsStressRead(t *testing.T) {
168
t.Fatal(err)
169
}
170
171
- read, err := coreunix.Cat(nd, item)
171
+ read, err := coreunix.Cat(nd.Context(), nd, item)
172
if err != nil {
173
t.Fatal(err)
174
}
test/integration/addcat_test.go
+1
-1
@@ -138,7 +138,7 @@ func DirectAddCat(data []byte, conf testutil.LatencyConfig) error {
138
return err
139
}
140
141
- readerCatted, err := coreunix.Cat(catter, added)
141
+ readerCatted, err := coreunix.Cat(ctx, catter, added)
142
if err != nil {
143
return err
144
}
test/integration/bench_cat_test.go
+1
-1
@@ -84,7 +84,7 @@ func benchCat(b *testing.B, data []byte, conf testutil.LatencyConfig) error {
84
}
85
86
b.StartTimer()
87
- readerCatted, err := coreunix.Cat(catter, added)
87
+ readerCatted, err := coreunix.Cat(ctx, catter, added)
88
if err != nil {
89
return err
90
}
test/integration/grandcentral_test.go
+1
-1
@@ -62,7 +62,7 @@ func RunSupernodeBootstrappedAddCat(data []byte, conf testutil.LatencyConfig) er
62
return err
63
}
64
65
- readerCatted, err := coreunix.Cat(catter, keyAdded)
65
+ readerCatted, err := coreunix.Cat(ctx, catter, keyAdded)
66
if err != nil {
67
return err
68
}
test/integration/three_legged_cat_test.go
+1
-1
@@ -117,7 +117,7 @@ func RunThreeLeggedCat(data []byte, conf testutil.LatencyConfig) error {
117
return err
118
}
119
120
- readerCatted, err := coreunix.Cat(catter, added)
120
+ readerCatted, err := coreunix.Cat(ctx, catter, added)
121
if err != nil {
122
return err
123
}
test/supernode_client/main.go
+1
-1
@@ -199,7 +199,7 @@ func runFileCattingWorker(ctx context.Context, n *core.IpfsNode) error {
199
"localPeer": n.Identity,
200
}
201
}))
202
- if r, err := coreunix.Cat(n, k); err != nil {
202
+ if r, err := coreunix.Cat(ctx, n, k); err != nil {
203
e.Done()
204
log.Printf("failed to cat file. seed: %d #%d key: %s err: %s", *seed, i, k, err)
205
} else {