restorer: Sanitize verify errors

This commit is contained in:
Michael Eischer 2021-09-19 13:21:57 +02:00
parent bdcdfaf6b4
commit 2cdc0719af
2 changed files with 5 additions and 1 deletions

View file

@ -351,6 +351,9 @@ func (res *Restorer) VerifyFiles(ctx context.Context, dst string) (int, error) {
for job := range work {
buf, err = res.verifyFile(job.path, job.node, buf)
if err != nil {
err = res.Error(job.path, err)
}
if err != nil || ctx.Err() != nil {
break
}
atomic.AddUint64(&nchecked, 1)

View file

@ -844,5 +844,6 @@ func TestVerifyCancel(t *testing.T) {
nverified, err := res.VerifyFiles(ctx, tempdir)
rtest.Equals(t, 0, nverified)
rtest.Assert(t, err != nil, "nil error from VerifyFiles")
rtest.Equals(t, []error(nil), errs)
rtest.Equals(t, 1, len(errs))
rtest.Assert(t, strings.Contains(errs[0].Error(), "Invalid file size for"), "wrong error %q", errs[0].Error())
}