From 7017adb7e9e40b0bb35593da4ade58f852b9e25c Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Thu, 9 May 2024 15:44:27 +0200 Subject: [PATCH] repository: retry failed ListPack once --- internal/repository/repository.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/repository/repository.go b/internal/repository/repository.go index 77652278f..1efaf4548 100644 --- a/internal/repository/repository.go +++ b/internal/repository/repository.go @@ -869,7 +869,17 @@ func (r *Repository) List(ctx context.Context, t restic.FileType, fn func(restic func (r *Repository) ListPack(ctx context.Context, id restic.ID, size int64) ([]restic.Blob, uint32, error) { h := backend.Handle{Type: restic.PackFile, Name: id.String()} - return pack.List(r.Key(), backend.ReaderAt(ctx, r.Backend(), h), size) + entries, hdrSize, err := pack.List(r.Key(), backend.ReaderAt(ctx, r.Backend(), h), size) + if err != nil { + if r.Cache != nil { + // ignore error as there is not much we can do here + _ = r.Cache.Forget(h) + } + + // retry on error + entries, hdrSize, err = pack.List(r.Key(), backend.ReaderAt(ctx, r.Backend(), h), size) + } + return entries, hdrSize, err } // Delete calls backend.Delete() if implemented, and returns an error