mirror of
https://github.com/restic/restic.git
synced 2025-08-22 07:07:26 +00:00
Merge pull request #3048 from aawsome/check-pack-index
check: check index for packs that are read
This commit is contained in:
@@ -727,6 +727,7 @@ func checkPack(ctx context.Context, r restic.Repository, id restic.ID) error {
|
||||
|
||||
var errs []error
|
||||
var buf []byte
|
||||
idx := r.Index()
|
||||
for i, blob := range blobs {
|
||||
debug.Log(" check blob %d: %v", i, blob)
|
||||
|
||||
@@ -762,6 +763,19 @@ func checkPack(ctx context.Context, r restic.Repository, id restic.ID) error {
|
||||
errs = append(errs, errors.Errorf("Blob ID does not match, want %v, got %v", blob.ID.Str(), hash.Str()))
|
||||
continue
|
||||
}
|
||||
|
||||
// Check if blob is contained in index
|
||||
idxHas := false
|
||||
for _, pb := range idx.Lookup(blob.ID, blob.Type) {
|
||||
if pb.PackID == id {
|
||||
idxHas = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !idxHas {
|
||||
errs = append(errs, errors.Errorf("Blob ID %v is not contained in index", blob.ID.Str()))
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if len(errs) > 0 {
|
||||
|
Reference in New Issue
Block a user