From 1020e9c3af1cd9d780af64f2c624bca19f2562d7 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 11 Oct 2015 20:55:28 +0200 Subject: [PATCH] Check for data blobs with null ID, improve errors --- checker/checker.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/checker/checker.go b/checker/checker.go index 7c6f2dad9..ec5f1da9a 100644 --- a/checker/checker.go +++ b/checker/checker.go @@ -523,18 +523,24 @@ func (c *Checker) checkTree(id backend.ID, tree *restic.Tree) (errs []error) { var blobs []backend.ID - for i, node := range tree.Nodes { + for _, node := range tree.Nodes { switch node.Type { case "file": - blobs = append(blobs, node.Content...) + 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)}) + continue + } + blobs = append(blobs, blobID) + } case "dir": if node.Subtree == nil { - errs = append(errs, Error{TreeID: &id, Err: fmt.Errorf("node %d is dir but has no subtree", i)}) + errs = append(errs, Error{TreeID: &id, Err: fmt.Errorf("dir node %q has no subtree", node.Name)}) continue } if node.Subtree.IsNull() { - errs = append(errs, Error{TreeID: &id, Err: fmt.Errorf("node %d is dir subtree id is null", i)}) + errs = append(errs, Error{TreeID: &id, Err: fmt.Errorf("dir node %q subtree id is null", node.Name)}) continue } }