app: defer system.I revert
All checks were successful
Test / Create distribution (push) Successful in 19s
Test / Run NixOS test (push) Successful in 49s

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 <cat@gensokyo.uk>
This commit is contained in:
2025-02-19 21:05:48 +09:00
parent ef81828e0c
commit 3c80fd2b0f
5 changed files with 152 additions and 147 deletions

View File

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