From 30983b149db71a3659800a5fd6946d2ef62d7044 Mon Sep 17 00:00:00 2001 From: simlecode Date: Mon, 17 May 2021 14:46:54 +0800 Subject: [PATCH] Clean the repo that failed to initialize --- cmd/daemon.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/daemon.go b/cmd/daemon.go index 691ab43889..0d0d30583a 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 {