forked from TrueCloudLab/restic
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
|
inCh = nil
|
||||||
|
|
||||||
case outCh <- job:
|
case outCh <- job:
|
||||||
|
debug.Log("checker.FilterTrees", "tree sent to check: %v", job.ID.Str())
|
||||||
outCh = nil
|
outCh = nil
|
||||||
inCh = in
|
inCh = in
|
||||||
}
|
}
|
||||||
|
@ -581,6 +582,10 @@ func (c *Checker) checkTree(id backend.ID, tree *restic.Tree) (errs []error) {
|
||||||
for _, node := range tree.Nodes {
|
for _, node := range tree.Nodes {
|
||||||
switch node.Type {
|
switch node.Type {
|
||||||
case "file":
|
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 {
|
for b, blobID := range node.Content {
|
||||||
if blobID.IsNull() {
|
if blobID.IsNull() {
|
||||||
errs = append(errs, Error{TreeID: id, Err: fmt.Errorf("file %q blob %d has null ID", node.Name, b)})
|
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)})
|
errs = append(errs, Error{TreeID: id, Err: fmt.Errorf("dir node %q subtree id is null", node.Name)})
|
||||||
continue
|
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…
Add table
Reference in a new issue