From 133ac42a0b3fa576f0283343eb6c1d9e63d39ca8 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sat, 29 Sep 2018 14:40:48 +0200 Subject: [PATCH] debug: check file content hash --- cmd/restic/cmd_debug.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cmd/restic/cmd_debug.go b/cmd/restic/cmd_debug.go index 1a5f971a7..2230c7b1c 100644 --- a/cmd/restic/cmd_debug.go +++ b/cmd/restic/cmd_debug.go @@ -15,6 +15,7 @@ import ( "github.com/spf13/cobra" "golang.org/x/sync/errgroup" + "github.com/restic/restic/internal/backend" "github.com/restic/restic/internal/crypto" "github.com/restic/restic/internal/errors" "github.com/restic/restic/internal/pack" @@ -347,6 +348,19 @@ func runDebugExamine(gopts GlobalOptions, args []string) error { } fmt.Printf(" file size is %v\n", fi.Size) + + buf, err := backend.LoadAll(gopts.ctx, nil, repo.Backend(), h) + if err != nil { + fmt.Fprintf(os.Stderr, "error: %v\n", err) + } + + gotID := restic.Hash(buf) + if !id.Equal(gotID) { + fmt.Printf(" wanted hash %v, got %v\n", id, gotID) + } else { + fmt.Printf(" hash for file content matches\n") + } + fmt.Printf(" ========================================\n") fmt.Printf(" looking for info in the indexes\n")