writePack method
Keeps the pack as it arrived, with the index this library builds beside
it — the layout git index-pack produces.
Implementation
@override
Future<void> writePack(Uint8List pack) async {
final parsed = await gitReadPack(pack, external: read);
final missing = <GitObject>[];
for (final o in parsed.objects) {
if (!await contains(o.object.id)) missing.add(o.object);
}
if (missing.isEmpty) return;
final name = 'pack-${GitObjectId.fromBytes(parsed.checksum).hex}';
_atomicWrite(p.join(_packDir, '$name.pack'), pack);
// The index last: a pack without its index is invisible, an index
// without its pack would be read.
_atomicWrite(p.join(_packDir, '$name.idx'), parsed.buildIndex());
_packs = null;
}