From 6d9675c323a093f33d7af8da7c948ce55a3a886b Mon Sep 17 00:00:00 2001
From: Michael Eischer <michael.eischer@fau.de>
Date: Sat, 14 Jan 2023 16:04:14 +0100
Subject: [PATCH] repository: cleanup error message on invalid data

The retry printed the filename twice:
```
Load(<lock/04804cba82>, 0, 0) returned error, retrying after 720.254544ms: load(<lock/04804cba82>): invalid data returned
```
now the warning has changed to
```
Load(<lock/04804cba82>, 0, 0) returned error, retrying after 720.254544ms: invalid data returned
```
---
 internal/repository/repository.go | 3 ++-
 internal/restic/repository.go     | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/internal/repository/repository.go b/internal/repository/repository.go
index a8d885a01..a5988b54c 100644
--- a/internal/repository/repository.go
+++ b/internal/repository/repository.go
@@ -204,7 +204,8 @@ func (r *Repository) LoadUnpacked(ctx context.Context, t restic.FileType, id res
 			} else {
 				cancel()
 			}
-			return errors.Errorf("load(%v): invalid data returned", h)
+			return restic.ErrInvalidData
+
 		}
 		return nil
 	})
diff --git a/internal/restic/repository.go b/internal/restic/repository.go
index c559b5aa3..e01d204e6 100644
--- a/internal/restic/repository.go
+++ b/internal/restic/repository.go
@@ -4,10 +4,14 @@ import (
 	"context"
 
 	"github.com/restic/restic/internal/crypto"
+	"github.com/restic/restic/internal/errors"
 	"github.com/restic/restic/internal/ui/progress"
 	"golang.org/x/sync/errgroup"
 )
 
+// ErrInvalidData is used to report that a file is corrupted
+var ErrInvalidData = errors.New("invalid data returned")
+
 // Repository stores data in a backend. It provides high-level functions and
 // transparently encrypts/decrypts data.
 type Repository interface {