Skip to content

Commit 413358a

Browse files
authored
cmd/geth: make import cmd exit with 1 if import errors occurred (#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>
1 parent 0c82928 commit 413358a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎cmd/geth/chaincmd.go‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,13 +299,17 @@ func importChain(ctx *cli.Context) error {
299299
// Import the chain
300300
start := time.Now()
301301

302+
var importErr error
303+
302304
if len(ctx.Args()) == 1 {
303305
if err := utils.ImportChain(chain, ctx.Args().First()); err != nil {
306+
importErr = err
304307
log.Error("Import error", "err", err)
305308
}
306309
} else {
307310
for _, arg := range ctx.Args() {
308311
if err := utils.ImportChain(chain, arg); err != nil {
312+
importErr = err
309313
log.Error("Import error", "file", arg, "err", err)
310314
}
311315
}
@@ -358,7 +362,7 @@ func importChain(ctx *cli.Context) error {
358362
utils.Fatalf("Failed to read database iostats: %v", err)
359363
}
360364
fmt.Println(ioStats)
361-
return nil
365+
return importErr
362366
}
363367

364368
func exportChain(ctx *cli.Context) error {

0 commit comments

Comments
 (0)