flush method
- String? path,
Flushes pending mutations for path (or the whole MFS when null or /)
and returns the CID of the flushed path.
The manager writes through on every mutation, so flushing waits for
in-flight operations and re-persists the root CID — matching
ipfs files flush [--path], which returns {"Cid": "<cid>"}.
Implementation
Future<CID> flush({String? path}) async {
final effectivePath = path ?? '/';
return _mutationLock.synchronized(() async {
final parts = _splitPath(effectivePath);
final cid = parts.isEmpty
? _rootCid
: await _resolvePath(_rootCid!, parts);
if (cid == null) {
throw Exception('Path not found: $effectivePath');
}
await _persistRoot();
return cid;
});
}