func ensureRepoInitialized(path string) error { if !fsrepo.IsInitialized(path) { conf, err := config.Init(ioutil.Discard, *nBitsForKeypair) if err != nil { return err } if err := fsrepo.Init(path, conf); err != nil { return err } } return nil }
func doInit(out io.Writer, repoRoot string, force bool, empty bool, nBitsForKeypair int) error { if _, err := fmt.Fprintf(out, "initializing ipfs node at %s\n", repoRoot); err != nil { return err } if err := checkWriteable(repoRoot); err != nil { return err } if fsrepo.IsInitialized(repoRoot) && !force { return errRepoExists } conf, err := config.Init(out, nBitsForKeypair) if err != nil { return err } if fsrepo.IsInitialized(repoRoot) { if err := fsrepo.Remove(repoRoot); err != nil { return err } } if err := fsrepo.Init(repoRoot, conf); err != nil { return err } if !empty { if err := addDefaultAssets(out, repoRoot); err != nil { return err } } return initializeIpnsKeyspace(repoRoot) }