write method

  1. @override
Future write(
  1. String atsign,
  2. AtKeys atKeys
)
override

Create-only initial persist (fresh onboard); implementations throw if the target already exists. Use flush to persist later mutations.

Implementation

@override
Future write(String atsign, AtKeys atKeys) async {
  final file = File(filePath!(atsign));
  await AtKeysFileLock(file.path).synchronized(() async {
    if (file.existsSync()) {
      throw AtKeysFileOverwriteException(
          'Tried writing ${file.path}, but failed since it already exists');
    }

    await _writeAtRestDocument(file, await _encodeAtRest(atKeys, atsign));
  });
}