Files
felhom.eu/hub/internal/store/snapshot.go
T

18 lines
677 B
Go

package store
import (
"context"
"fmt"
)
// SnapshotInto writes a consistent, compacted copy of the whole database to path with SQLite's `VACUUM INTO`
// (R-173, hub v0.136.0). One statement inside one read transaction: it sees one point in time and includes every
// committed write still sitting in hub.db-wal — unlike copying hub.db (+ -wal) as files while the hub writes. The
// target must not exist. Pinned by internal/dbsnap (TestSnapshot_*).
func (s *Store) SnapshotInto(ctx context.Context, path string) error {
if _, err := s.db.ExecContext(ctx, `VACUUM INTO ?`, path); err != nil {
return fmt.Errorf("store: VACUUM INTO %s: %w", path, err)
}
return nil
}