diff --git a/internal/repository/index.go b/internal/repository/index.go index 139b5a173..92f0da0e9 100644 --- a/internal/repository/index.go +++ b/internal/repository/index.go @@ -176,24 +176,6 @@ func (idx *Index) Lookup(bh restic.BlobHandle, pbs []restic.PackedBlob) []restic return pbs } -// ListPack returns a list of blobs contained in a pack. -func (idx *Index) ListPack(id restic.ID) (pbs []restic.PackedBlob) { - idx.m.Lock() - defer idx.m.Unlock() - - for typ := range idx.byType { - m := &idx.byType[typ] - m.foreach(func(e *indexEntry) bool { - if idx.packs[e.packIndex] == id { - pbs = append(pbs, idx.toPackedBlob(e, restic.BlobType(typ))) - } - return true - }) - } - - return pbs -} - // Has returns true iff the id is listed in the index. func (idx *Index) Has(bh restic.BlobHandle) bool { idx.m.Lock() diff --git a/internal/repository/index_test.go b/internal/repository/index_test.go index 138555100..dab52a6bc 100644 --- a/internal/repository/index_test.go +++ b/internal/repository/index_test.go @@ -2,6 +2,7 @@ package repository_test import ( "bytes" + "context" "math/rand" "sync" "testing" @@ -336,7 +337,7 @@ func TestIndexUnserialize(t *testing.T) { rtest.Equals(t, oldIdx, idx.Supersedes()) - blobs := idx.ListPack(exampleLookupTest.packID) + blobs := listPack(idx, exampleLookupTest.packID) if len(blobs) != len(exampleLookupTest.blobs) { t.Fatalf("expected %d blobs in pack, got %d", len(exampleLookupTest.blobs), len(blobs)) } @@ -353,6 +354,15 @@ func TestIndexUnserialize(t *testing.T) { } } +func listPack(idx *repository.Index, id restic.ID) (pbs []restic.PackedBlob) { + for pb := range idx.Each(context.TODO()) { + if pb.PackID.Equal(id) { + pbs = append(pbs, pb) + } + } + return pbs +} + var ( benchmarkIndexJSON []byte benchmarkIndexJSONOnce sync.Once