From b8c7543a551697e6b9534ced5f6ed0f375ad22de Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Fri, 6 Nov 2020 23:32:31 +0100 Subject: [PATCH] check: Merge 'size could not be found' and 'not found in index' errors By construction these two errors always show up in pairs: 'size could not be found' is printed when the blob is not found in the repository index. That blob is also part of the `blobs` array. Later on, check iterates over that array and checks whether the blob is marked as existing. Which cannot be the case as that mark is generated by iterating over the repository index. The merged warning no longer reports the blob index within a file. That information could also be derived by printing the affected tree using `cat` and searching for the blob. --- internal/checker/checker.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 05c131055..6466693c4 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -656,7 +656,8 @@ func (c *Checker) checkTree(id restic.ID, tree *restic.Tree) (errs []error) { 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)}) + debug.Log("tree %v references blob %v which isn't contained in index", id, blobID) + errs = append(errs, Error{TreeID: id, Err: errors.Errorf("file %q blob %v not found in index", node.Name, blobID)}) } size += uint64(blobSize) } @@ -686,10 +687,6 @@ func (c *Checker) checkTree(id restic.ID, tree *restic.Tree) (errs []error) { for _, blobID := range blobs { c.blobRefs.Lock() h := restic.BlobHandle{ID: blobID, Type: restic.DataBlob} - if (c.blobRefs.M[h] & blobStatusExists) == 0 { - debug.Log("tree %v references blob %v which isn't contained in index", id, blobID) - errs = append(errs, Error{TreeID: id, BlobID: blobID, Err: errors.New("not found in index")}) - } c.blobRefs.M[h] |= blobStatusReferenced debug.Log("blob %v is referenced", blobID) c.blobRefs.Unlock()