Skip to content

Commit

Permalink
Merge pull request #3102 from ipfs/feat/local-add
Browse files Browse the repository at this point in the history
ipfs/add: make --local flag not write out providers
  • Loading branch information
whyrusleeping committed Aug 21, 2016
2 parents 19779b3 + 4b27885 commit 8ffab98
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion core/commands/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import (
"github.com/ipfs/go-ipfs/core/coreunix"
"gx/ipfs/QmeWjRodbcZFKe5tMN7poEx3izym6osrLSnTLf9UjJZBbs/pb"

blockservice "github.com/ipfs/go-ipfs/blockservice"
cmds "github.com/ipfs/go-ipfs/commands"
files "github.com/ipfs/go-ipfs/commands/files"
core "github.com/ipfs/go-ipfs/core"
offline "github.com/ipfs/go-ipfs/exchange/offline"
dag "github.com/ipfs/go-ipfs/merkledag"
dagtest "github.com/ipfs/go-ipfs/merkledag/test"
mfs "github.com/ipfs/go-ipfs/mfs"
ft "github.com/ipfs/go-ipfs/unixfs"
Expand Down Expand Up @@ -146,10 +149,18 @@ You can now refer to the added file in a gateway, like so:
n = nilnode
}

dserv := n.DAG
local, _, _ := req.Option("local").Bool()
if local {
offlineexch := offline.Exchange(n.Blockstore)
bserv := blockservice.New(n.Blockstore, offlineexch)
dserv = dag.NewDAGService(bserv)
}

outChan := make(chan interface{}, 8)
res.SetOutput((<-chan interface{})(outChan))

fileAdder, err := coreunix.NewAdder(req.Context(), n.Pinning, n.Blockstore, n.DAG)
fileAdder, err := coreunix.NewAdder(req.Context(), n.Pinning, n.Blockstore, dserv)
if err != nil {
res.SetError(err, cmds.ErrNormal)
return
Expand Down

0 comments on commit 8ffab98

Please sign in to comment.