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.
This commit is contained in:
Andrew Ayer 2017-01-06 12:23:20 -08:00
parent 0d9b81ecc8
commit c8f0a0f9e8
1 changed files with 5 additions and 3 deletions

View File

@ -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