mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-30 18:13:54 +08:00
cmd/init: Fixed init checking if config exists
This commit is contained in:
@ -32,9 +32,13 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func initCmd(c *commander.Command, inp []string) error {
|
func initCmd(c *commander.Command, inp []string) error {
|
||||||
_, err := os.Lstat(config.DefaultConfigFilePath)
|
filename, err := config.Filename(config.DefaultConfigFilePath)
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("Couldn't get home directory path")
|
||||||
|
}
|
||||||
|
fi, err := os.Lstat(filename)
|
||||||
force := c.Flag.Lookup("f").Value.Get().(bool)
|
force := c.Flag.Lookup("f").Value.Get().(bool)
|
||||||
if err != nil && !force {
|
if fi != nil || (err != nil && !os.IsNotExist(err)) && !force {
|
||||||
return errors.New("ipfs configuration file already exists!\nReinitializing would overwrite your keys.\n(use -f to force overwrite)")
|
return errors.New("ipfs configuration file already exists!\nReinitializing would overwrite your keys.\n(use -f to force overwrite)")
|
||||||
}
|
}
|
||||||
cfg := new(config.Config)
|
cfg := new(config.Config)
|
||||||
|
Reference in New Issue
Block a user