retry: Do not retry Stat() if file does not exist

In non test/debug code, Stat() is used exclusively to check whether a
file exists. Thus, do not retry if a file is reported as not existing.
This commit is contained in:
Michael Eischer 2022-12-03 11:42:48 +01:00
parent 40ac678252
commit 648edeca40
2 changed files with 30 additions and 0 deletions

View file

@ -139,6 +139,10 @@ func (be *Backend) Stat(ctx context.Context, h restic.Handle) (fi restic.FileInf
var innerError error
fi, innerError = be.Backend.Stat(ctx, h)
if be.Backend.IsNotExist(innerError) {
// do not retry if file is not found, as stat is usually used to check whether a file exists
return backoff.Permanent(innerError)
}
return innerError
})
return fi, err