From c8f0a0f9e81a63977b439e00385021c860509932 Mon Sep 17 00:00:00 2001 From: Andrew Ayer Date: Fri, 6 Jan 2017 12:23:20 -0800 Subject: [PATCH] Only write once file if run was 100% successful Otherwise, if a single log was unreachable, we'd be force to download all of it on the next run. --- cmd/common.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/common.go b/cmd/common.go index 6be4fdc..a31d512 100644 --- a/cmd/common.go +++ b/cmd/common.go @@ -326,9 +326,11 @@ func Main(statePath string, processCallback certspotter.ProcessCallback) int { exitCode |= processLog(&logs[i], processCallback) } - if err := state.Finish(); err != nil { - fmt.Fprintf(os.Stderr, "%s: Error finalizing state: %s\n", os.Args[0], err) - exitCode |= 1 + if state.IsFirstRun() && exitCode == 0 { + if err := state.Finish(); err != nil { + fmt.Fprintf(os.Stderr, "%s: Error finalizing state: %s\n", os.Args[0], err) + exitCode |= 1 + } } return exitCode