validateRestore method
- StateSnapshot snapshot, {
- bool quiescent = false,
Validates a complete snapshot manifest without mutating participants.
Implementation
void validateRestore(StateSnapshot snapshot, {bool quiescent = false}) {
if (snapshot.records.length != _participants.length) {
throw ArgumentError('Snapshot participant count does not match the '
'registered design.');
}
final recordsByPath = <String, StateSnapshotRecord>{};
for (final record in snapshot.records) {
if (recordsByPath.putIfAbsent(record.path, () => record) != record) {
throw ArgumentError('Snapshot contains duplicate participant '
'${record.path}.');
}
}
for (final participant in _orderedParticipants) {
final record = recordsByPath[participant.path];
if (record == null) {
throw ArgumentError(
'Snapshot is missing participant ${participant.path}.');
}
if (record.path != participant.path ||
record.schemaKind != participant.schemaKind ||
record.schemaVersion != participant.schemaVersion ||
record.configurationIdentity != participant.configurationIdentity) {
throw ArgumentError('Snapshot manifest does not match participant '
'${participant.path}.');
}
participant.capabilities.validateRequest(
StateTransactionOperation.restore,
quiescent: quiescent,
);
}
}