open static method
Implementation
static Future<Wal> open(String path, {required VfsAdapter vfs}) async {
final wal = Wal._(path, vfs);
// Resume LSN from the highest valid record in the existing WAL.
try {
final bytes = await vfs.readAll(path);
if (bytes.isNotEmpty) {
final content = const Utf8Decoder(allowMalformed: true).convert(bytes);
for (final line in content.split('\n').reversed) {
if (line.trim().isEmpty) continue;
final rec = WalRecord.tryDecode(line);
if (rec != null) {
wal._lsn = rec.lsn;
wal._flushedLsn = rec.lsn;
break;
}
}
}
} catch (_) {}
return wal;
}