From 9f3ff8765a96eb338f815fb44284b7bac2d2a8b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 25 Oct 2017 19:59:27 +0200 Subject: [PATCH] proider: fix coreunix tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Ɓukasz Magiera --- core/commands/add.go | 4 +++- core/coreunix/add.go | 9 +++++---- core/coreunix/add_test.go | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/commands/add.go b/core/commands/add.go index 32435eda9a6..a7b6bdd2b45 100644 --- a/core/commands/add.go +++ b/core/commands/add.go @@ -227,15 +227,17 @@ You can now refer to the added file in a gateway, like so: } exch := n.Exchange + prov := n.Providers local, _, _ := req.Option("local").Bool() if local { exch = offline.Exchange(addblockstore) + prov = offline.Providers() } bserv := blockservice.New(addblockstore, exch) dserv := dag.NewDAGService(bserv) - fileAdder, err := coreunix.NewAdder(req.Context(), n.Pinning, n.Blockstore, dserv) + fileAdder, err := coreunix.NewAdder(req.Context(), n.Pinning, n.Blockstore, dserv, prov) if err != nil { res.SetError(err, cmds.ErrNormal) return diff --git a/core/coreunix/add.go b/core/coreunix/add.go index b7e679c7464..973296a757e 100644 --- a/core/coreunix/add.go +++ b/core/coreunix/add.go @@ -74,12 +74,13 @@ type AddedObject struct { Size string `json:",omitempty"` } -func NewAdder(ctx context.Context, p pin.Pinner, bs bstore.GCBlockstore, ds dag.DAGService) (*Adder, error) { +func NewAdder(ctx context.Context, p pin.Pinner, bs bstore.GCBlockstore, ds dag.DAGService, pr providers.Interface) (*Adder, error) { return &Adder{ ctx: ctx, pinning: p, blockstore: bs, dagService: ds, + provide: pr, Progress: false, Hidden: true, Pin: true, @@ -314,7 +315,7 @@ func Add(n *core.IpfsNode, r io.Reader) (string, error) { func AddWithContext(ctx context.Context, n *core.IpfsNode, r io.Reader) (string, error) { defer n.Blockstore.PinLock().Unlock() - fileAdder, err := NewAdder(n.Context(), n.Pinning, n.Blockstore, n.DAG) + fileAdder, err := NewAdder(n.Context(), n.Pinning, n.Blockstore, n.DAG, n.Providers) if err != nil { return "", err } @@ -342,7 +343,7 @@ func AddR(n *core.IpfsNode, root string) (key string, err error) { } defer f.Close() - fileAdder, err := NewAdder(n.Context(), n.Pinning, n.Blockstore, n.DAG) + fileAdder, err := NewAdder(n.Context(), n.Pinning, n.Blockstore, n.DAG, n.Providers) if err != nil { return "", err } @@ -366,7 +367,7 @@ func AddR(n *core.IpfsNode, root string) (key string, err error) { // the directory, and and error if any. func AddWrapped(n *core.IpfsNode, r io.Reader, filename string) (string, node.Node, error) { file := files.NewReaderFile(filename, filename, ioutil.NopCloser(r), nil) - fileAdder, err := NewAdder(n.Context(), n.Pinning, n.Blockstore, n.DAG) + fileAdder, err := NewAdder(n.Context(), n.Pinning, n.Blockstore, n.DAG, n.Providers) if err != nil { return "", nil, err } diff --git a/core/coreunix/add_test.go b/core/coreunix/add_test.go index add4395eb5e..c2c7bca3ad9 100644 --- a/core/coreunix/add_test.go +++ b/core/coreunix/add_test.go @@ -60,7 +60,7 @@ func TestAddGCLive(t *testing.T) { } out := make(chan interface{}) - adder, err := NewAdder(context.Background(), node.Pinning, node.Blockstore, node.DAG) + adder, err := NewAdder(context.Background(), node.Pinning, node.Blockstore, node.DAG, node.Providers) if err != nil { t.Fatal(err) } @@ -171,7 +171,7 @@ func testAddWPosInfo(t *testing.T, rawLeaves bool) { bs := &testBlockstore{GCBlockstore: node.Blockstore, expectedPath: "/tmp/foo.txt", t: t} bserv := blockservice.New(bs, node.Exchange) dserv := dag.NewDAGService(bserv) - adder, err := NewAdder(context.Background(), node.Pinning, bs, dserv) + adder, err := NewAdder(context.Background(), node.Pinning, bs, dserv, node.Providers) if err != nil { t.Fatal(err) }