repository: unwrap BlobHandle parameters of LookupBlob

The method now uses the same parameters as LookupBlobSize.
This commit is contained in:
Michael Eischer committed 2024-05-24 21:33:17 +02:00
1 parent 1266a4932f
commit 864995271e
10 files changed
+18 -18

No files matched your search

+1 -1
View File
@@ -161,7 +161,7 @@ func checkPackInner(ctx context.Context, r *Repository, id restic.ID, blobs []re
for _, blob := range blobs {
// Check if blob is contained in index and position is correct
idxHas := false
for _, pb := range r.LookupBlob(blob.BlobHandle) {
for _, pb := range r.LookupBlob(blob.BlobHandle.Type, blob.BlobHandle.ID) {
if pb.PackID == id && pb.Blob == blob {
idxHas = true
break
+3 -3
View File
@@ -146,7 +146,7 @@ func findPacksForBlobs(t *testing.T, repo restic.Repository, blobs restic.BlobSe
packs := restic.NewIDSet()
for h := range blobs {
list := repo.LookupBlob(h)
list := repo.LookupBlob(h.Type, h.ID)
if len(list) == 0 {
t.Fatal("Failed to find blob", h.ID.Str(), "with type", h.Type)
}
@@ -247,7 +247,7 @@ func testRepack(t *testing.T, version uint) {
}
for h := range keepBlobs {
list := repo.LookupBlob(h)
list := repo.LookupBlob(h.Type, h.ID)
if len(list) == 0 {
t.Errorf("unable to find blob %v in repo", h.ID.Str())
continue
@@ -311,7 +311,7 @@ func testRepackCopy(t *testing.T, version uint) {
reloadIndex(t, dstRepo)
for h := range keepBlobs {
list := dstRepo.LookupBlob(h)
list := dstRepo.LookupBlob(h.Type, h.ID)
if len(list) == 0 {
t.Errorf("unable to find blob %v in repo", h.ID.Str())
continue
+2 -2
View File
@@ -578,8 +578,8 @@ func (r *Repository) Connections() uint {
return r.be.Connections()
}
func (r *Repository) LookupBlob(bh restic.BlobHandle) []restic.PackedBlob {
return r.idx.Lookup(bh)
func (r *Repository) LookupBlob(tpe restic.BlobType, id restic.ID) []restic.PackedBlob {
return r.idx.Lookup(restic.BlobHandle{Type: tpe, ID: id})
}
// LookupBlobSize returns the size of blob id.
+2 -2
View File
@@ -161,7 +161,7 @@ func TestLoadBlobBroken(t *testing.T) {
data, err := repo.LoadBlob(context.TODO(), restic.TreeBlob, id, nil)
rtest.OK(t, err)
rtest.Assert(t, bytes.Equal(buf, data), "data mismatch")
pack := repo.LookupBlob(restic.BlobHandle{Type: restic.TreeBlob, ID: id})[0].PackID
pack := repo.LookupBlob(restic.TreeBlob, id)[0].PackID
rtest.Assert(t, c.Has(backend.Handle{Type: restic.PackFile, Name: pack.String()}), "expected tree pack to be cached")
}
@@ -439,7 +439,7 @@ func TestListPack(t *testing.T) {
repo.UseCache(c)
// Forcibly cache pack file
packID := repo.LookupBlob(restic.BlobHandle{Type: restic.TreeBlob, ID: id})[0].PackID
packID := repo.LookupBlob(restic.TreeBlob, id)[0].PackID
rtest.OK(t, be.Load(context.TODO(), backend.Handle{Type: restic.PackFile, IsMetadata: true, Name: packID.String()}, 0, 0, func(rd io.Reader) error { return nil }))
// Get size to list pack