From 1291470bf0a53f02e6b485b3bb7a778ac7db93cd Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Thu, 15 Jan 2015 12:09:01 -0800 Subject: [PATCH] use core_io/Add in commands/init/writeWelcomeFile --- cmd/ipfs/init.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/cmd/ipfs/init.go b/cmd/ipfs/init.go index 7afa23e70..b09083af2 100644 --- a/cmd/ipfs/init.go +++ b/cmd/ipfs/init.go @@ -10,8 +10,7 @@ import ( cmds "github.com/jbenet/go-ipfs/commands" core "github.com/jbenet/go-ipfs/core" corecmds "github.com/jbenet/go-ipfs/core/commands" - imp "github.com/jbenet/go-ipfs/importer" - chunk "github.com/jbenet/go-ipfs/importer/chunk" + core_io "github.com/jbenet/go-ipfs/core/io" ci "github.com/jbenet/go-ipfs/p2p/crypto" peer "github.com/jbenet/go-ipfs/p2p/peer" repo "github.com/jbenet/go-ipfs/repo" @@ -117,7 +116,6 @@ func doInit(repoRoot string, force bool, nBitsForKeypair int) (interface{}, erro // addTheWelcomeFile adds a file containing the welcome message to the newly // minted node. On success, it calls onSuccess func addTheWelcomeFile(repoRoot string) error { - // TODO extract this file creation operation into a function ctx, cancel := context.WithCancel(context.Background()) defer cancel() r := fsrepo.At(repoRoot) @@ -132,13 +130,7 @@ func addTheWelcomeFile(repoRoot string) error { // Set up default file reader := bytes.NewBufferString(welcomeMsg) - - defnd, err := imp.BuildDagFromReader(reader, nd.DAG, nd.Pinning.GetManual(), chunk.DefaultSplitter) - if err != nil { - return err - } - - k, err := defnd.Key() + k, err := core_io.Add(nd, reader) if err != nil { return fmt.Errorf("failed to write test file: %s", err) }