Fix bd-144: Update main .db file timestamp after import (WAL mode)

- Added CheckpointWAL method to SQLite storage
- Import now checkpoints WAL after completion
- Updates main .db file modification time for staleness detection
- PRAGMA wal_checkpoint(FULL) flushes WAL to main database
This commit is contained in:
Steve Yegge
2025-10-25 16:37:54 -07:00
parent de03466da9
commit aada5d9ac6
3 changed files with 19 additions and 2 deletions

View File

@@ -2062,3 +2062,12 @@ func (s *SQLiteStorage) UnderlyingDB() *sql.DB {
func (s *SQLiteStorage) UnderlyingConn(ctx context.Context) (*sql.Conn, error) {
return s.db.Conn(ctx)
}
// CheckpointWAL checkpoints the WAL file to flush changes to the main database file.
// This updates the main .db file's modification time, which is important for staleness detection.
// In WAL mode, writes go to the -wal file, leaving the main .db file untouched.
// Checkpointing flushes the WAL to the main database file.
func (s *SQLiteStorage) CheckpointWAL(ctx context.Context) error {
_, err := s.db.ExecContext(ctx, "PRAGMA wal_checkpoint(FULL)")
return err
}