readBundle method
A medium that fetches a member when it is asked for.
It used to fetch every blob under the container path before returning,
which made a save cost the document's whole edit history: .history/
lives under that path, so a one-word change to a 200-section document
with a year of snapshots pulled thousands of blobs to decide it needed to
write one. The listing is one request and answers listFiles and
exists; only the files a caller actually reads cost a getBlob, so a
save is proportional to the sections it compares and never touches
.history/ at all.
Not detached any more, and it cannot be — a lazy medium is a live view by
definition. The guarantee that nothing reaches the repository until
commit moved to TomRecordingBundleMedium, which buffers writes and is
what every save goes through.
Implementation
@override
Future<TomBundleMedium> readBundle(String locator) async {
final loc = await _locate(locator);
final snapshot = await _snapshot(loc);
final blobs = snapshot?.tree.blobsUnder(loc.path) ?? const {};
if (blobs.isEmpty) throw TomContainerNotFoundException(locator);
return TomReadOnlyBundleMedium(
_LazyBlobMedium(
storage: this,
loc: loc,
locator: locator,
shas: {for (final blob in blobs.entries) blob.key: blob.value.sha!},
),
);
}