checkpointSqlite method

Future<void> checkpointSqlite()

Flush any pending -wal content into the main SQLite file and delete the WAL. After this returns the on-disk main file is the canonical image and the diff baseline is reset.

Implementation

Future<void> checkpointSqlite() async {
  if (path == null || !_persistAsSqlite) return;
  final bytes = _buildSqliteBytes(pageSize: _sqlitePageSize);
  await _atomicWriteBytes(path!, bytes);
  _sqliteBaselineBytes = Uint8List.fromList(bytes);
  for (final p in ['${path!}-wal', '${path!}-wal2', '${path!}-wal2.meta']) {
    final wf = File(p);
    if (await wf.exists()) await wf.delete();
  }
  _wal2Counter = 0;
}