prune: Include ID of all missing blobs in error message

This commit is contained in:
Michael Eischer 2020-03-31 23:31:33 +02:00
parent d8b80e9862
commit 08d24ff99e
2 changed files with 9 additions and 4 deletions

View File

@ -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))

View File

@ -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)