SetTargetTime rebuilds the page index to view the database at a specific time.
(ctx context.Context, timestamp time.Time)
| 1164 | |
| 1165 | // SetTargetTime rebuilds the page index to view the database at a specific time. |
| 1166 | func (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, ×tamp) |
| 1185 | } |
| 1186 | |
| 1187 | // ResetTime rebuilds the page index to the latest available state. |
| 1188 | func (f *VFSFile) ResetTime(ctx context.Context) error { |
no test coverage detected