From 623770eebbf30315e24685aa3c68b8dc633c3c79 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 17 Jul 2022 12:11:54 +0200 Subject: [PATCH] repository: try to recover from invalid blob while repacking If a blob that should be kept is invalid, Repack will now try to request the blob using LoadBlob. Only return an error if that fails. --- internal/repository/repack.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/repository/repack.go b/internal/repository/repack.go index 0a50bfcf4..bf6b65c8f 100644 --- a/internal/repository/repack.go +++ b/internal/repository/repack.go @@ -73,7 +73,13 @@ func repack(ctx context.Context, repo restic.Repository, dstRepo restic.Reposito for t := range downloadQueue { err := StreamPack(wgCtx, repo.Backend().Load, repo.Key(), t.PackID, t.Blobs, func(blob restic.BlobHandle, buf []byte, err error) error { if err != nil { - return err + var ierr error + // check whether we can get a valid copy somewhere else + buf, ierr = repo.LoadBlob(wgCtx, blob.Type, blob.ID, nil) + if ierr != nil { + // no luck, return the original error + return err + } } keepMutex.Lock()