diff --git a/cmd/daemon.go b/cmd/daemon.go index ceaef8ac43..efd7a9670c 100644 --- a/cmd/daemon.go +++ b/cmd/daemon.go @@ -83,6 +83,14 @@ var daemonCmd = &cmds.Command{ return err } if !exist { + defer func() { + if err != nil { + log.Infof("Failed to initialize venus, cleaning up %s after attempt...", repoDir) + if err := os.RemoveAll(repoDir); err != nil { + log.Errorf("Failed to clean up failed repo: %s", err) + } + } + }() log.Infof("Initializing repo at '%s'", repoDir) if err := re.Emit(repoDir); err != nil {