snapshot method
Returns a snapshot of this entry. This opens all streams eagerly to guarantee that we see a single published snapshot. If we opened streams lazily then the streams could come from different edits.
Implementation
Future<Snapshot?> snapshot() async {
if (!readable) return null;
if (!_cache._civilizedFileSystem && (currentEditor != null || zombie)) {
return null;
}
final sources = <Source>[];
final lengths = List.of(this.lengths, growable: false);
try {
for (var i = 0; i < valueCount; i++) {
sources.add(await _newSource(i));
}
return Snapshot._(_cache, key, sequenceNumber, sources, lengths);
} on FileSystemException {
// A file must have been deleted manually!
for (final source in sources) {
try {
await source.close();
} catch (_) {}
}
// Since the entry is no longer valid, remove it so the metadata is
// accurate (i.e. the cache size.)
try {
await _cache._removeEntry(this);
} catch (_) {}
return null;
}
}