diff options
Diffstat (limited to 'internal/engine/plan.go')
| -rw-r--r-- | internal/engine/plan.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/internal/engine/plan.go b/internal/engine/plan.go index bf4c64c..b136bdf 100644 --- a/internal/engine/plan.go +++ b/internal/engine/plan.go @@ -34,6 +34,14 @@ type DirPlan struct { // directories claiming one destination resolve the collision instead of // both silently landing on it. func (e *Engine) Plan(ctx context.Context, d *Dir, claims *plan.Claims) (*DirPlan, error) { + return e.PlanAt(ctx, d, claims, e.Now()) +} + +// PlanAt is Plan with the run's own clock: {now:FMT} is "the start of the +// run" (spec ยง7.3), so every directory of one run stamps the same moment. +// Reading the clock per directory let a review pause split one run's output +// across two folders, and across midnight across two dates. +func (e *Engine) PlanAt(ctx context.Context, d *Dir, claims *plan.Claims, now time.Time) (*DirPlan, error) { started := time.Now() r, err := e.Match(ctx, d) if err != nil { @@ -45,7 +53,7 @@ func (e *Engine) Plan(ctx context.Context, d *Dir, claims *plan.Claims) (*DirPla inputs[i] = plan.Input{File: fm.File, Rules: planRules(fm.Rules), NoDelete: fm.NoDelete} } - chains := plan.Build(d.Root, inputs, e.Now(), plan.OS{}, claims) + chains := plan.Build(d.Root, inputs, now, plan.OS{}, claims) return &DirPlan{Dir: d, Chains: chains, Result: r, Elapsed: time.Since(started)}, nil } |
