forked from TrueCloudLab/restic
checker: Check metadata size and blob sizes
This commit is contained in:
parent
a069467e72
commit
83ca08245b
1 changed files with 12 additions and 0 deletions
|
@ -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 a new issue