aboutsummaryrefslogtreecommitdiff
path: root/gui/internal/model
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-16 09:28:32 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-16 09:28:32 +0200
commit27eb6353030953e91a45b0104bd0567e53622090 (patch)
tree3867b5741a9e524fcda33c8a574dcbda61faabf3 /gui/internal/model
parentbcfeb773afcc28641ef2fb47749c91fd0767054a (diff)
downloadkrino-27eb6353030953e91a45b0104bd0567e53622090.tar.gz
krino-27eb6353030953e91a45b0104bd0567e53622090.zip
gui: row menu for trash or permanent delete; Apply frees the directory
Diffstat (limited to 'gui/internal/model')
-rw-r--r--gui/internal/model/plan.go10
-rw-r--r--gui/internal/model/plan_test.go19
2 files changed, 26 insertions, 3 deletions
diff --git a/gui/internal/model/plan.go b/gui/internal/model/plan.go
index 7496347..4066eae 100644
--- a/gui/internal/model/plan.go
+++ b/gui/internal/model/plan.go
@@ -73,9 +73,10 @@ func Plan(ctx context.Context, sess *engine.Session, d *engine.Dir) (*PlanTab, e
return t, nil
}
-// Close releases the directory's lock. The session outlives the tab, so
-// closing one plan to open another keeps the run - and its claims - going.
-// Closing twice is not an error.
+// Close releases the directory's lock, which Apply also does once the plan
+// is history. The session outlives the tab, so closing one plan to open
+// another keeps the run - and its claims - going. Closing twice is not an
+// error.
func (t *PlanTab) Close() error {
if t.lock == nil {
return nil
@@ -221,6 +222,9 @@ func (t *PlanTab) Apply(ctx context.Context) (*engine.ApplyResult, error) {
// used is free again, while one it did use stays protected for the rest
// of the run (spec §7.4).
t.sess.FinishDirectory()
+ // An applied plan is history, so the directory is free again without
+ // closing the window (GUI design §3).
+ t.Close()
if res != nil {
t.record(res)
}
diff --git a/gui/internal/model/plan_test.go b/gui/internal/model/plan_test.go
index 8b7e32f..bf8f19f 100644
--- a/gui/internal/model/plan_test.go
+++ b/gui/internal/model/plan_test.go
@@ -212,6 +212,25 @@ func TestPlanHoldsTheLock(t *testing.T) {
}
}
+// TestApplyReleasesTheLock: once a plan has been applied it is history, so
+// the directory is free again without closing the window (GUI design §3).
+func TestApplyReleasesTheLock(t *testing.T) {
+ conf := "(path \"~/dl\")\n(rule \"all\" (move \"Out\"))\n"
+ e, _ := sandboxDir(t, conf, map[string]string{"a.pdf": "one"})
+ tab, _ := planTab(t, e)
+ if _, err := tab.Apply(context.Background()); err != nil {
+ t.Fatal(err)
+ }
+ l, err := lock.Acquire(context.Background(), e.Config.LockFile("dl"), false)
+ if err != nil {
+ t.Fatalf("applying did not release the lock: %v", err)
+ }
+ l.Release()
+ if err := tab.Close(); err != nil {
+ t.Errorf("closing an applied tab: %v", err)
+ }
+}
+
// TestPlanRefusesAHeldDirectory: a directory another krino is working in is
// not planned at all, and the message names it.
func TestPlanRefusesAHeldDirectory(t *testing.T) {