SetBase establishes a new base (snapshot) at the provided commit and resets the attached caches, then deletes all prior commits.
(ctx context.Context, commit ksuid.KSUID)
| 416 | // SetBase establishes a new base (snapshot) at the provided commit and resets |
| 417 | // the attached caches, then deletes all prior commits. |
| 418 | func (s *Store) SetBase(ctx context.Context, commit ksuid.KSUID) ([]ksuid.KSUID, error) { |
| 419 | path, err := s.Path(ctx, commit) |
| 420 | if err != nil { |
| 421 | return nil, err |
| 422 | } |
| 423 | if len(path) <= 1 { |
| 424 | return nil, errors.New("cannot set base on earliest commit") |
| 425 | } |
| 426 | // Create snapshot of previous commit. |
| 427 | snap, err := s.buildSnapshot(ctx, path[1]) |
| 428 | if err != nil { |
| 429 | return nil, err |
| 430 | } |
| 431 | if err := s.putBase(ctx, snap, path[1]); err != nil { |
| 432 | return nil, err |
| 433 | } |
| 434 | s.cache.Purge() |
| 435 | s.paths.Purge() |
| 436 | s.snapshots.Purge() |
| 437 | s.snapshots.Add(path[1], snap) |
| 438 | return path[1:], s.deletePath(ctx, path[1:]) |
| 439 | } |
| 440 | |
| 441 | // DANGER ZONE - commits should only be removed once a new base has been |
| 442 | // established. |
no test coverage detected