abandonForCrashTest method

Future<void> abandonForCrashTest()

Test-only. Close the data and journal file handles WITHOUT committing dirty pages or deleting the journal. This is what a real process crash would look like to the next PagedFile.open: the journal stays on disk, recording the pre-transaction image of every page that was modified, and recovery rolls those pages back.

Implementation

Future<void> abandonForCrashTest() async {
  if (_closed) return;
  _closed = true;
  _dirty.clear();
  _journaled.clear();
  _cache.clear();
  final d = _data;
  _data = null;
  if (d != null) {
    try {
      await d.close();
    } catch (_) {/* best-effort */}
  }
  final j = _journal;
  _journal = null;
  if (j != null) {
    try {
      await j.close();
    } catch (_) {/* best-effort */}
  }
  // Deliberately DO NOT delete the journal file.
}