mirror of
https://github.com/octoleo/restic.git
synced 2024-12-23 03:18:55 +00:00
checker: Check metadata size and blob sizes
This commit is contained in:
parent
a069467e72
commit
83ca08245b
@ -569,12 +569,24 @@ func (c *Checker) checkTree(id restic.ID, tree *restic.Tree) (errs []error) {
|
||||
errs = append(errs, Error{TreeID: id, Err: errors.Errorf("file %q has nil blob list", node.Name)})
|
||||
}
|
||||
|
||||
var size uint64
|
||||
for b, blobID := range node.Content {
|
||||
if blobID.IsNull() {
|
||||
errs = append(errs, Error{TreeID: id, Err: errors.Errorf("file %q blob %d has null ID", node.Name, b)})
|
||||
continue
|
||||
}
|
||||
blobs = append(blobs, blobID)
|
||||
blobSize, found := c.repo.LookupBlobSize(blobID, restic.DataBlob)
|
||||
if !found {
|
||||
errs = append(errs, Error{TreeID: id, Err: errors.Errorf("file %q blob %d size could not be found", node.Name, b)})
|
||||
}
|
||||
size += uint64(blobSize)
|
||||
}
|
||||
if size != node.Size {
|
||||
errs = append(errs, Error{
|
||||
TreeID: id,
|
||||
Err: errors.Errorf("file %q: metadata size (%v) and sum of blob sizes (%v) do not match", node.Name, node.Size, size),
|
||||
})
|
||||
}
|
||||
case "dir":
|
||||
if node.Subtree == nil {
|
||||
|
Loading…
Reference in New Issue
Block a user