repository: Simplify Blob equality check

This commit is contained in:
Michael Eischer 2022-02-13 16:50:50 +01:00
parent 243698680a
commit 6408686973
2 changed files with 2 additions and 2 deletions

View file

@ -542,7 +542,7 @@ func checkPack(ctx context.Context, r restic.Repository, id restic.ID, blobs []r
// Check if blob is contained in index and position is correct // Check if blob is contained in index and position is correct
idxHas := false idxHas := false
for _, pb := range idx.Lookup(blob.BlobHandle) { for _, pb := range idx.Lookup(blob.BlobHandle) {
if pb.PackID == id && pb.Offset == blob.Offset && pb.Length == blob.Length { if pb.PackID == id && pb.Blob == blob {
idxHas = true idxHas = true
break break
} }

View file

@ -543,7 +543,7 @@ func (idx *Index) merge(idx2 *Index) error {
m.foreachWithID(e2.id, func(e *indexEntry) { m.foreachWithID(e2.id, func(e *indexEntry) {
b := idx.toPackedBlob(e, restic.BlobType(typ)) b := idx.toPackedBlob(e, restic.BlobType(typ))
b2 := idx2.toPackedBlob(e2, restic.BlobType(typ)) b2 := idx2.toPackedBlob(e2, restic.BlobType(typ))
if b.Length == b2.Length && b.Offset == b2.Offset && b.PackID == b2.PackID { if b == b2 {
found = true found = true
} }
}) })