cmd/geth: propagate import error when --nocompaction is set

importChain records the first import failure in importErr, logs it, and
returns it at the end of the function so that "geth import" exits with a
non-zero status on failure. However, the --nocompaction early return
returned nil instead of importErr, so an import that failed while that
flag was set was reported as success (exit code 0).

This silently masked import failures from any script or CI step that
relies on the exit code. Return importErr from the early-return path as
well, matching the normal (compacting) path.
This commit is contained in:
cuiweixie 2026-06-11 20:00:00 +08:00
parent eea6242742
commit 8837035b57

View file

@ -420,7 +420,7 @@ func importChain(ctx *cli.Context) error {
fmt.Printf("GC pause: %v\n\n", time.Duration(mem.PauseTotalNs))
if ctx.Bool(utils.NoCompactionFlag.Name) {
return nil
return importErr
}
// Compact the entire database to more accurately measure disk io and print the stats