Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mb1896 committed Sep 20, 2023
1 parent 0033544 commit 10a9eb2
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion cmd/lotus/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,27 @@ var DaemonCmd = &cli.Command{
willImportChain = true
}

if cctx.Bool("remove-existing-chain") || willImportChain {
willRemoveChain := cctx.Bool("remove-existing-chain")
if willImportChain && !willRemoveChain {
// Confirm with the user about the intention to remove chain data.
reader := bufio.NewReader(os.Stdin)
fmt.Print("Importing chain or snapshot will by default delete existing local chain data. Do you want to proceed and delete? (yes/no): ")
userInput, err := reader.ReadString('\n')
if err != nil {
return xerrors.Errorf("reading user input: %w", err)
}
userInput = strings.ToLower(strings.TrimSpace(userInput))

if userInput == "yes" {
willRemoveChain = true
} else if userInput == "no" {
willRemoveChain = false
} else {
return fmt.Errorf("Invalid input. Please answer with 'yes' or 'no'.")
}
}

if willRemoveChain {
lr, err := repo.NewFS(cctx.String("repo"))
if err != nil {
return xerrors.Errorf("error opening fs repo: %w", err)
Expand Down

0 comments on commit 10a9eb2

Please sign in to comment.