From 3c80fd2b0f907af7b179e9e307304c0fa52994a0 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Wed, 19 Feb 2025 21:05:48 +0900 Subject: app: defer system.I revert Just returning an error after a successful call of commit will leave garbage behind with no way for the caller to clean them. This change ensures revert is always called after successful commit with at least per-process state enabled. Signed-off-by: Ophestra --- main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'main.go') diff --git a/main.go b/main.go index c1aee941..7896a199 100644 --- a/main.go +++ b/main.go @@ -334,7 +334,7 @@ func runApp(config *fst.Config) { fmsg.PrintBaseError(err, "cannot seal app:") internal.Exit(1) } else if err = a.Run(ctx, rs); err != nil { - if !rs.Start { + if rs.Time == nil { fmsg.PrintBaseError(err, "cannot start app:") } else { logWaitError(err) @@ -344,6 +344,12 @@ func runApp(config *fst.Config) { rs.ExitCode = 126 } } + if rs.RevertErr != nil { + fmsg.PrintBaseError(rs.RevertErr, "generic error returned during cleanup:") + if rs.ExitCode == 0 { + rs.ExitCode = 128 + } + } if rs.WaitErr != nil { log.Println("inner wait failed:", rs.WaitErr) } -- cgit v1.3.1