aboutsummaryrefslogtreecommitdiff
path: root/internal/engine/apply.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 23:07:57 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 23:07:57 +0200
commitc66a842ce4679a3ffa5504dad39b1402bea75e9f (patch)
tree9e9db5e569b9f16a4ca4e66d0a5b0f456a186ece /internal/engine/apply.go
parentb013e5fb87580e4cab0d85a0d2c8bb402c610413 (diff)
downloadkrino-c66a842ce4679a3ffa5504dad39b1402bea75e9f.tar.gz
krino-c66a842ce4679a3ffa5504dad39b1402bea75e9f.zip
plan 10 re-check: cut run column, damaged undo run, emptied directory cleanup, text turning binary, explain flags, interrupt docsv0.0.7
Diffstat (limited to 'internal/engine/apply.go')
-rw-r--r--internal/engine/apply.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/internal/engine/apply.go b/internal/engine/apply.go
index f9cb9ef..46026ba 100644
--- a/internal/engine/apply.go
+++ b/internal/engine/apply.go
@@ -308,6 +308,14 @@ func (e *Engine) Runs(n int) ([]journal.Run, error) {
type UndoPlan struct {
Run string
Files []UndoFile
+
+ // Cleanup holds files with nothing left to reverse but directories the
+ // run made that something else occupied when the plan was built (re-review
+ // undo F3). They are not offered - that would repeat on every undo - but
+ // ApplyUndo removes any of those directories the other reversals leave
+ // empty, and logs it (plan 10 re-check R1). A front end that rebuilds the
+ // plan must carry Cleanup over.
+ Cleanup []UndoFile
}
// UndoFile is the reversal of one file's chain, last original step first.
@@ -414,6 +422,7 @@ func (e *Engine) PlanUndo(runID string) (*UndoPlan, error) {
// the run made that something else still occupies: offering them
// would repeat on every undo (re-review undo F3). An empty one is
// still offered, and removed.
+ up.Cleanup = append(up.Cleanup, uf)
continue
}
up.Files = append(up.Files, uf)
@@ -445,7 +454,9 @@ func onlyOccupiedDirectoryRemovals(steps []UndoStep) bool {
func isUndoRun(entries []journal.Entry) bool {
any := false
for _, en := range entries {
- if en.Action == "run-start" || en.Action == "run-end" {
+ // A damaged line says nothing about which kind of run this is (plan
+ // 10 re-check R3).
+ if en.Action == "run-start" || en.Action == "run-end" || en.Action == "damaged" {
continue
}
any = true
@@ -873,6 +884,11 @@ func (e *Engine) ApplyUndo(ctx context.Context, up *UndoPlan, j *journal.Writer,
}
}
+ for _, f := range up.Cleanup {
+ for i, us := range f.Steps {
+ retries = append(retries, dirRetry{dir: us.Src, dirName: f.Dir, file: f.File, step: i + 1, log: true})
+ }
+ }
if err := e.retryDirRemovals(j, run, retries); err != nil {
return result, fmt.Errorf("engine: apply undo: %w", err)
}