setInfo method
Sets the partition info indexed by key
.
name
: The partition namekey
: The keyinfo
: The info
Implementation
@override
Future<void> setInfo(String name, String key, I info) {
return _adapter
.partitionFile(name, key)
.open(mode: FileMode.append)
.then((raf) {
final pre = lock
? (RandomAccessFile f) => f.lock(FileLock.blockingExclusive)
: (RandomAccessFile f) => Future.value(f);
final pos =
lock ? () => raf.unlock().then((f) => f.close()) : () => raf.close();
return pre(raf)
.then((f) => f.setPosition(0))
.then((f) => f.writeFrom(_writeInfo(info).takeBytes()))
.whenComplete(pos)
.then((_) => null);
});
}