@cryptotaxi247 / kubo / commits / 0d88f70c6

feat(init): remove datastore path override

Brian Tiger Chow committed Jan 12, 2015 at 12:15 UTC 0d88f70c6e5c1d368eb698402e58dc27da20aebb
1 file changed +11 -23
cmd/ipfs/init.go
+11 -23
@@ -35,7 +35,6 @@ var initCmd = &cmds.Command{
35 cmds.IntOption("bits", "b", "Number of bits to use in the generated RSA private key (defaults to 4096)"),
36 cmds.StringOption("passphrase", "p", "Passphrase for encrypting the private key"),
37 cmds.BoolOption("force", "f", "Overwrite existing config (if it exists)"),
38 - cmds.StringOption("datastore", "d", "Location for the IPFS data store"),
38
39 // TODO need to decide whether to expose the override as a file or a
40 // directory. That is: should we allow the user to also specify the
@@ -44,11 +43,6 @@ var initCmd = &cmds.Command{
43 },
44 Run: func(req cmds.Request) (interface{}, error) {
45
47 - dspathOverride, _, err := req.Option("d").String() // if !found it's okay. Let == ""
48 - if err != nil {
49 - return nil, err
50 - }
51 -
46 force, _, err := req.Option("f").Bool() // if !found, it's okay force == false
47 if err != nil {
48 return nil, err
@@ -62,7 +56,7 @@ var initCmd = &cmds.Command{
56 nBitsForKeypair = nBitsForKeypairDefault
57 }
58
65 - return doInit(req.Context().ConfigRoot, dspathOverride, force, nBitsForKeypair)
59 + return doInit(req.Context().ConfigRoot, force, nBitsForKeypair)
60 },
61 }
62
@@ -87,11 +81,11 @@ For a short demo of what you can do, enter 'ipfs tour'
81 `
82
83 func initWithDefaults(configRoot string) error {
90 - _, err := doInit(configRoot, "", false, nBitsForKeypairDefault)
84 + _, err := doInit(configRoot, false, nBitsForKeypairDefault)
85 return debugerror.Wrap(err)
86 }
87
94 -func doInit(configRoot string, dspathOverride string, force bool, nBitsForKeypair int) (interface{}, error) {
88 +func doInit(configRoot string, force bool, nBitsForKeypair int) (interface{}, error) {
89
90 u.POut("initializing ipfs node at %s\n", configRoot)
91
@@ -99,7 +93,7 @@ func doInit(configRoot string, dspathOverride string, force bool, nBitsForKeypai
93 return nil, errCannotInitConfigExists
94 }
95
102 - conf, err := initConfig(dspathOverride, nBitsForKeypair)
96 + conf, err := initConfig(nBitsForKeypair)
97 if err != nil {
98 return nil, err
99 }
@@ -151,28 +145,22 @@ func addTheWelcomeFile(conf *config.Config) error {
145 return nil
146 }
147
154 -func datastoreConfig(dspath string) (config.Datastore, error) {
148 +func datastoreConfig() (config.Datastore, error) {
149 ds := config.Datastore{}
156 - if len(dspath) == 0 {
157 - var err error
158 - dspath, err = config.DataStorePath("")
159 - if err != nil {
160 - return ds, err
161 - }
150 + dspath, err := config.DataStorePath("")
151 + if err != nil {
152 + return ds, err
153 }
154 ds.Path = dspath
155 ds.Type = "leveldb"
165 -
166 - err := initCheckDir(dspath)
167 - if err != nil {
156 + if err := initCheckDir(dspath); err != nil {
157 return ds, debugerror.Errorf("datastore: %s", err)
158 }
170 -
159 return ds, nil
160 }
161
174 -func initConfig(dspathOverride string, nBitsForKeypair int) (*config.Config, error) {
175 - ds, err := datastoreConfig(dspathOverride)
162 +func initConfig(nBitsForKeypair int) (*config.Config, error) {
163 + ds, err := datastoreConfig()
164 if err != nil {
165 return nil, err
166 }