MCPcopy
hub / github.com/benbjohnson/litestream / SetTargetTime

Method SetTargetTime

vfs.go:1166–1185  ·  view source on GitHub ↗

SetTargetTime rebuilds the page index to view the database at a specific time.

(ctx context.Context, timestamp time.Time)

Source from the content-addressed store, hash-verified

1164
1165// SetTargetTime rebuilds the page index to view the database at a specific time.
1166func (f *VFSFile) SetTargetTime(ctx context.Context, timestamp time.Time) error {
1167 if timestamp.IsZero() {
1168 return fmt.Errorf("target time required")
1169 }
1170
1171 infos, err := CalcRestorePlan(ctx, f.client, 0, timestamp, f.logger)
1172 if err != nil {
1173 return fmt.Errorf("cannot calc restore plan: %w", err)
1174 } else if len(infos) == 0 {
1175 return fmt.Errorf("no backup files available")
1176 }
1177
1178 // Disable hydrated reads during time travel - hydrated file is at latest state
1179 if f.hydrator != nil && f.hydrator.Complete() {
1180 f.hydrator.Disable()
1181 f.logger.Debug("hydration disabled for time travel", "target", timestamp)
1182 }
1183
1184 return f.rebuildIndex(ctx, infos, &timestamp)
1185}
1186
1187// ResetTime rebuilds the page index to the latest available state.
1188func (f *VFSFile) ResetTime(ctx context.Context) error {

Callers 2

FileControlMethod · 0.95
SetVFSConnectionTimeFunction · 0.80

Calls 5

rebuildIndexMethod · 0.95
CalcRestorePlanFunction · 0.85
IsZeroMethod · 0.80
CompleteMethod · 0.80
DisableMethod · 0.80

Tested by

no test coverage detected