1 files changed, 11 insertions, 2 deletions
diff --git a/LibGit/GitRepo.cs b/LibGit/GitRepo.cs
index a58bc38..045df6c 100644
--- a/LibGit/GitRepo.cs
+++ b/LibGit/GitRepo.cs
@@ -54,6 +54,12 @@ public class GitRepo
public async IAsyncEnumerable<GitPack> GetPacks()
{
+ if (!await RepoSource.FileExists("objects/info/packs"))
+ {
+ Console.WriteLine("No pack index found.");
+ yield break;
+ }
+
var fs = await RepoSource.GetFileStream("objects/info/packs");
Console.WriteLine("Found packs file:");
fs.Peek(32).HexDump(32);
@@ -62,17 +68,20 @@ public class GitRepo
Console.WriteLine("WARNING: No packs found!");
yield break;
}
+
while (fs.Remaining() > 0 && fs.Peek() != 0x0A)
{
//example: P pack-24bd1c46d657f74f40629503d8e5083a9ad36a67.pack
var line = fs.ReadTerminatedField((byte)'\n').AsString();
if (line.StartsWith("P "))
{
- new GitPackIndex().Read(await RepoSource.GetFileStream($"objects/pack/{line[2..].Replace(".pack", ".idx")}"));
+ Console.WriteLine($"Reading pack: {RepoSource.BasePath}/objects/pack/{line[2..]}");
+ var packStream = await RepoSource.GetFileStream($"objects/pack/{line[2..]}");
+ var idxStream = await RepoSource.GetFileStream($"objects/pack/{line[2..].Replace(".pack", ".idx")}");
yield return new GitPack(
packId: line[2..],
repo: this
- ).Read(await RepoSource.GetFileStream($"objects/pack/{line[2..]}"));
+ ).Read(packStream, idxStream);
}
else
{
|