diff options
Diffstat (limited to 'gui/internal/model/history.go')
| -rw-r--r-- | gui/internal/model/history.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gui/internal/model/history.go b/gui/internal/model/history.go index 7c166bb..87ab6e7 100644 --- a/gui/internal/model/history.go +++ b/gui/internal/model/history.go @@ -114,6 +114,10 @@ type UndoTab struct { sess *engine.Session up *engine.UndoPlan locks []*lock.Lock + + // applying is set while the reversal is in flight; Close refuses then, + // for the reason PlanTab.applying gives. + applying bool } // PlanUndo builds the reversal of runID and locks every directory it @@ -208,6 +212,8 @@ func (t *UndoTab) SelectedCount() int { // said no to (spec ยง9). Refused files ride along unchanged, as they do on // the command line. The locks are released afterwards: the plan is history. func (t *UndoTab) Apply(ctx context.Context) (*engine.ApplyResult, error) { + t.applying = true + defer func() { t.applying = false }() toApply := &engine.UndoPlan{Run: t.up.Run, Cleanup: t.up.Cleanup} for i, f := range t.up.Files { if f.Refused == "" && !t.Rows[i].Selected { @@ -266,6 +272,9 @@ func undoOutcome(row UndoRow, fr engine.FileResult) string { // does. One lock's failure never stops the rest from being released, or the // session from being closed. Closing twice is not an error. func (t *UndoTab) Close() error { + if t.applying { + return ErrApplying + } var first error for _, l := range t.locks { if err := l.Release(); err != nil && first == nil { |
