replaceIfUnchanged method

  1. @override
Future<void> replaceIfUnchanged(
  1. CassetteSnapshot snapshot,
  2. List<int> bytes
)
override

Replaces snapshot with encoded bytes only if its revision is current.

Throws a revision-changed CassetteStoreException when the stored value changed after snapshot was read. A store without this capability throws an unsupported-operation CassetteStoreException.

Implementation

@override
Future<void> replaceIfUnchanged(
  CassetteSnapshot snapshot,
  List<int> bytes,
) {
  final copied = _copyWriteBytes(
    snapshot.name,
    bytes,
    operation: CassetteStoreOperation.replaceIfUnchanged,
  );
  return _serialiseWrite(
    snapshot.name,
    () => _replaceIfUnchanged(snapshot, copied),
  );
}