SqliteFile.fromBytesWithWal constructor
Parse a database together with its WAL companion. Frames in walBytes
are validated by checksum and salt; any committed frames override the
pages in dbBytes. If the WAL has no valid commit (or walBytes is
null/empty) the result is identical to SqliteFile.fromBytes.
Throws FormatException if the WAL header is malformed or its page-size disagrees with the database header.
Implementation
factory SqliteFile.fromBytesWithWal(Uint8List dbBytes, Uint8List? walBytes) {
final hdr = SqliteHeader.parse(dbBytes);
if (walBytes == null || walBytes.length < _walHeaderSize) {
return SqliteFile._(dbBytes, hdr);
}
final wal = _parseWal(walBytes, hdr.pageSize);
if (wal == null) return SqliteFile._(dbBytes, hdr);
return SqliteFile._(
dbBytes,
hdr,
walOverrides: wal.pages,
logicalPageCount: wal.dbSizeInPages,
);
}