reopen method

  1. @override
Future<void> reopen()
override

Re-opens the underlying storage descriptor after an external compaction replaced the file on disk.

Implementation

@override
Future<void> reopen() async {
  if (_closed) {
    throw StateError('IoStorageBackend ($path) is closed');
  }
  final oldRaf = _raf;
  _knownPos = -1;
  final mode = readOnly ? FileMode.read : FileMode.append;
  if (ioMode != .async) {
    _raf = keepHandleOpen ? File(path).openSync(mode: mode) : null;
    oldRaf?.closeSync();
    return;
  }
  _raf = keepHandleOpen ? await File(path).open(mode: mode) : null;
  if (oldRaf != null) {
    await oldRaf.close();
  }
}