summaryrefslogtreecommitdiff
path: root/internal/engine/session.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/engine/session.go')
-rw-r--r--internal/engine/session.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/internal/engine/session.go b/internal/engine/session.go
index 8d5977a..09cf246 100644
--- a/internal/engine/session.go
+++ b/internal/engine/session.go
@@ -5,6 +5,7 @@ package engine
import (
"context"
"fmt"
+ "time"
"git.labunix.xyz/krino/internal/journal"
"git.labunix.xyz/krino/internal/lock"
@@ -27,6 +28,10 @@ type Session struct {
claims *plan.Claims
landed []string // where this run's applied files ended up, in order
dry bool
+
+ // started is the run's own clock: what {now:FMT} means for every
+ // directory of this run, fixed when the session begins.
+ started time.Time
}
// NewSession starts a run. The log is opened by OpenLog, or by the first
@@ -35,7 +40,7 @@ type Session struct {
// create a log a dry run would not. The caller closes the session when the
// run is over.
func (e *Engine) NewSession(dry bool) (*Session, error) {
- return &Session{e: e, claims: plan.NewClaims(), dry: dry}, nil
+ return &Session{e: e, claims: plan.NewClaims(), dry: dry, started: e.Now()}, nil
}
// OpenLog opens the log and takes the run id, once. A dry session does
@@ -86,9 +91,10 @@ func (s *Session) LockDirs(ctx context.Context, names []string, wait bool) ([]*l
return held, nil
}
-// Plan builds d's plan with the run's claims.
+// Plan builds d's plan with the run's claims, and the run's clock: every
+// directory of one run stamps {now:FMT} with the same moment.
func (s *Session) Plan(ctx context.Context, d *Dir) (*DirPlan, error) {
- return s.e.Plan(ctx, d, s.claims)
+ return s.e.PlanAt(ctx, d, s.claims, s.started)
}
// Apply carries out the approved files of dp and logs the run's steps,