mirror of
https://github.com/restic/restic.git
synced 2024-12-25 01:06:39 +00:00
check: Add more checks for nodes
This commit is contained in:
parent
7572586ded
commit
a996dbb9d6
1 changed files with 12 additions and 0 deletions
|
@ -534,6 +534,7 @@ func filterTrees(backlog backend.IDs, loaderChan chan<- backend.ID, in <-chan tr
|
|||
inCh = nil
|
||||
|
||||
case outCh <- job:
|
||||
debug.Log("checker.FilterTrees", "tree sent to check: %v", job.ID.Str())
|
||||
outCh = nil
|
||||
inCh = in
|
||||
}
|
||||
|
@ -581,6 +582,10 @@ func (c *Checker) checkTree(id backend.ID, tree *restic.Tree) (errs []error) {
|
|||
for _, node := range tree.Nodes {
|
||||
switch node.Type {
|
||||
case "file":
|
||||
if node.Content == nil {
|
||||
errs = append(errs, Error{TreeID: id, Err: fmt.Errorf("file %q has nil blob list", node.Name)})
|
||||
}
|
||||
|
||||
for b, blobID := range node.Content {
|
||||
if blobID.IsNull() {
|
||||
errs = append(errs, Error{TreeID: id, Err: fmt.Errorf("file %q blob %d has null ID", node.Name, b)})
|
||||
|
@ -598,6 +603,13 @@ func (c *Checker) checkTree(id backend.ID, tree *restic.Tree) (errs []error) {
|
|||
errs = append(errs, Error{TreeID: id, Err: fmt.Errorf("dir node %q subtree id is null", node.Name)})
|
||||
continue
|
||||
}
|
||||
|
||||
default:
|
||||
errs = append(errs, Error{TreeID: id, Err: fmt.Errorf("node %q with invalid type %q", node.Name, node.Type)})
|
||||
}
|
||||
|
||||
if node.Name == "" {
|
||||
errs = append(errs, Error{TreeID: id, Err: errors.New("node with empty name")})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue