use core_io/Add in commands/init/writeWelcomeFile
Brian Tiger Chow committed
Jan 15, 2015 at 12:09 UTC
1291470bf0a53f02e6b485b3bb7a778ac7db93cd
1 file changed
+2
-10
cmd/ipfs/init.go
+2
-10
@@ -10,8 +10,7 @@ import (
10
cmds "github.com/jbenet/go-ipfs/commands"
11
core "github.com/jbenet/go-ipfs/core"
12
corecmds "github.com/jbenet/go-ipfs/core/commands"
13
- imp "github.com/jbenet/go-ipfs/importer"
14
- chunk "github.com/jbenet/go-ipfs/importer/chunk"
13
+ core_io "github.com/jbenet/go-ipfs/core/io"
14
ci "github.com/jbenet/go-ipfs/p2p/crypto"
15
peer "github.com/jbenet/go-ipfs/p2p/peer"
16
repo "github.com/jbenet/go-ipfs/repo"
@@ -117,7 +116,6 @@ func doInit(repoRoot string, force bool, nBitsForKeypair int) (interface{}, erro
116
// addTheWelcomeFile adds a file containing the welcome message to the newly
117
// minted node. On success, it calls onSuccess
118
func addTheWelcomeFile(repoRoot string) error {
120
- // TODO extract this file creation operation into a function
119
ctx, cancel := context.WithCancel(context.Background())
120
defer cancel()
121
r := fsrepo.At(repoRoot)
@@ -132,13 +130,7 @@ func addTheWelcomeFile(repoRoot string) error {
130
131
// Set up default file
132
reader := bytes.NewBufferString(welcomeMsg)
135
-
136
- defnd, err := imp.BuildDagFromReader(reader, nd.DAG, nd.Pinning.GetManual(), chunk.DefaultSplitter)
137
- if err != nil {
138
- return err
139
- }
140
-
141
- k, err := defnd.Key()
133
+ k, err := core_io.Add(nd, reader)
134
if err != nil {
135
return fmt.Errorf("failed to write test file: %s", err)
136
}