From 08d24ff99e257fae8853b006ce686ff24aa34702 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Tue, 31 Mar 2020 23:31:33 +0200 Subject: [PATCH] prune: Include ID of all missing blobs in error message --- cmd/restic/cmd_prune.go | 11 ++++++++--- cmd/restic/integration_test.go | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/restic/cmd_prune.go b/cmd/restic/cmd_prune.go index 0cda6da15..fcddc76b1 100644 --- a/cmd/restic/cmd_prune.go +++ b/cmd/restic/cmd_prune.go @@ -191,13 +191,18 @@ func pruneRepository(gopts GlobalOptions, repo restic.Repository) error { return err } + var missingBlobs []restic.BlobHandle for h := range usedBlobs { if _, ok := blobCount[h]; !ok { - return errors.Fatalf("At least one data blob seems to be missing, aborting prune to prevent further data loss!\n" + - "Please report this error (along with the output of the 'prune' run) at\n" + - "https://github.com/restic/restic/issues/new") + missingBlobs = append(missingBlobs, h) } } + if len(missingBlobs) > 0 { + return errors.Fatalf("%v not found in the new index\n"+ + "Data blobs seem to be missing, aborting prune to prevent further data loss!\n"+ + "Please report this error (along with the output of the 'prune' run) at\n"+ + "https://github.com/restic/restic/issues/new/choose", missingBlobs) + } Verbosef("found %d of %d data blobs still in use, removing %d blobs\n", len(usedBlobs), stats.blobs, stats.blobs-len(usedBlobs)) diff --git a/cmd/restic/integration_test.go b/cmd/restic/integration_test.go index 2fdd2f4ec..1267db0a0 100644 --- a/cmd/restic/integration_test.go +++ b/cmd/restic/integration_test.go @@ -1277,7 +1277,7 @@ func TestPruneWithDamagedRepository(t *testing.T) { if err == nil { t.Fatalf("expected prune to fail") } - if !strings.Contains(err.Error(), "blob seems to be missing") { + if !strings.Contains(err.Error(), "blobs seem to be missing") { t.Fatalf("did not find hint for missing blobs") } t.Log(err)