mirror of
https://github.com/octoleo/restic.git
synced 2024-12-23 03:18:55 +00:00
repository: remove unused index.ListPack
This commit is contained in:
parent
e4f20dea61
commit
8ef2968f28
@ -176,24 +176,6 @@ func (idx *Index) Lookup(bh restic.BlobHandle, pbs []restic.PackedBlob) []restic
|
|||||||
return pbs
|
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.
|
// Has returns true iff the id is listed in the index.
|
||||||
func (idx *Index) Has(bh restic.BlobHandle) bool {
|
func (idx *Index) Has(bh restic.BlobHandle) bool {
|
||||||
idx.m.Lock()
|
idx.m.Lock()
|
||||||
|
@ -2,6 +2,7 @@ package repository_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
@ -336,7 +337,7 @@ func TestIndexUnserialize(t *testing.T) {
|
|||||||
|
|
||||||
rtest.Equals(t, oldIdx, idx.Supersedes())
|
rtest.Equals(t, oldIdx, idx.Supersedes())
|
||||||
|
|
||||||
blobs := idx.ListPack(exampleLookupTest.packID)
|
blobs := listPack(idx, exampleLookupTest.packID)
|
||||||
if len(blobs) != len(exampleLookupTest.blobs) {
|
if len(blobs) != len(exampleLookupTest.blobs) {
|
||||||
t.Fatalf("expected %d blobs in pack, got %d", len(exampleLookupTest.blobs), len(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 (
|
var (
|
||||||
benchmarkIndexJSON []byte
|
benchmarkIndexJSON []byte
|
||||||
benchmarkIndexJSONOnce sync.Once
|
benchmarkIndexJSONOnce sync.Once
|
||||||
|
Loading…
Reference in New Issue
Block a user