restic: list pack header via ListPackHandles

Replace ListPack with ListPackHandles so callers only receive blob
handles from pack headers, not layout fields.
This commit is contained in:
Michael Eischer
2026-06-04 21:58:23 +02:00
parent 8169814b38
commit a9e0b46358
8 changed files with 38 additions and 26 deletions
+4 -4
View File
@@ -103,17 +103,17 @@ func testPackAndBlobCounts(t testing.TB, gopts global.Options) (countTreePacks i
defer unlock()
rtest.OK(t, repo.List(context.TODO(), restic.PackFile, func(id restic.ID, size int64) error {
blobs, err := repo.ListPack(context.TODO(), id, size)
handles, err := repo.ListPackHandles(context.TODO(), id, size)
rtest.OK(t, err)
rtest.Assert(t, len(blobs) > 0, "a packfile should contain at least one blob")
rtest.Assert(t, len(handles) > 0, "a packfile should contain at least one blob")
switch blobs[0].Type {
switch handles[0].Type {
case restic.TreeBlob:
countTreePacks++
case restic.DataBlob:
countDataPacks++
}
countBlobs += len(blobs)
countBlobs += len(handles)
return nil
}))
return nil
+6 -6
View File
@@ -473,18 +473,18 @@ func (f *Finder) packsToBlobs(ctx context.Context, packs []string) error {
delete(packIDs, idStr)
}
debug.Log("Found pack %s", idStr)
blobs, err := f.repo.ListPack(ctx, id, size)
handles, err := f.repo.ListPackHandles(ctx, id, size)
if err != nil {
return err
}
for _, b := range blobs {
switch b.Type {
for _, h := range handles {
switch h.Type {
case restic.DataBlob:
f.blobIDs[b.ID.String()] = struct{}{}
f.blobIDs[h.ID.String()] = struct{}{}
case restic.TreeBlob:
f.treeIDs[b.ID.String()] = struct{}{}
f.treeIDs[h.ID.String()] = struct{}{}
default:
panic(fmt.Sprintf("unknown type %v in blob list", b.Type.String()))
panic(fmt.Sprintf("unknown type %v in blob list", h.Type.String()))
}
}
// Stop searching when all packs have been found