Skip to content

Commit

Permalink
cmd/geth: make import cmd exit with 1 if import errors occurred (ethe…
Browse files Browse the repository at this point in the history
…reum#21244)

The import command should not return a 0 status
code if the import finishes prematurely becaues
of an import error.

Returning the error causes the program to exit with 1
if the err is non nil.

Signed-off-by: meows <b5c6@protonmail.com>
  • Loading branch information
meowsbits committed Jun 24, 2020
1 parent 0c82928 commit 413358a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,17 @@ func importChain(ctx *cli.Context) error {
// Import the chain
start := time.Now()

var importErr error

if len(ctx.Args()) == 1 {
if err := utils.ImportChain(chain, ctx.Args().First()); err != nil {
importErr = err
log.Error("Import error", "err", err)
}
} else {
for _, arg := range ctx.Args() {
if err := utils.ImportChain(chain, arg); err != nil {
importErr = err
log.Error("Import error", "file", arg, "err", err)
}
}
Expand Down Expand Up @@ -358,7 +362,7 @@ func importChain(ctx *cli.Context) error {
utils.Fatalf("Failed to read database iostats: %v", err)
}
fmt.Println(ioStats)
return nil
return importErr
}

func exportChain(ctx *cli.Context) error {
Expand Down

0 comments on commit 413358a

Please sign in to comment.