getSnapshotMetadata method
SessionStore.getSnapshot by snapshotId without the state: the returned
row carries every other field as stored, with state null, and the same
null-if-not-found contract.
Implementation
@override
Future<SessionSnapshot?> getSnapshotMetadata(
String snapshotId, {
Map<String, dynamic>? context,
}) async {
normalizeGetSnapshotOptions(snapshotId: snapshotId);
final file = await _fileFor(snapshotId, context);
if (!file.existsSync()) return null;
// Let a corrupt / unreadable file throw, exactly as the full read
// (`_snapshotById`) does, so a caller can tell corruption apart from "not
// found" (a truncated file must not read as a missing snapshot).
final json = jsonDecode(await file.readAsString()) as Map<String, dynamic>;
// Promote the resolved sessionId before dropping `state` so identity (and
// the pointer fast path in `getLatestSnapshotMetadata`) survives a row that
// carried it only under `state`; then drop `state` so the (possibly large)
// payload is never materialized into a SessionState.
final sessionId =
(json['sessionId'] as String?) ??
(json['state'] as Map<String, dynamic>?)?['sessionId'] as String?;
json.remove('state');
if (sessionId != null) json['sessionId'] = sessionId;
return SessionSnapshot.fromJson(json);
}