restore: split error reporting from downloadPack

This commit is contained in:
Michael Eischer 2024-01-07 12:20:31 +01:00
parent 00d18b7a88
commit 2267910418

View file

@ -244,7 +244,21 @@ func (r *fileRestorer) downloadPack(ctx context.Context, pack *packInfo) error {
processedBlobs := restic.NewBlobSet() processedBlobs := restic.NewBlobSet()
err := r.downloadBlobs(ctx, pack.id, blobs, processedBlobs) err := r.downloadBlobs(ctx, pack.id, blobs, processedBlobs)
return r.reportError(blobs, processedBlobs, err)
}
func (r *fileRestorer) sanitizeError(file *fileInfo, err error) error {
if err != nil { if err != nil {
err = r.Error(file.location, err)
}
return err
}
func (r *fileRestorer) reportError(blobs blobToFileOffsetsMapping, processedBlobs restic.BlobSet, err error) error {
if err == nil {
return nil
}
// only report error for not yet processed blobs // only report error for not yet processed blobs
affectedFiles := make(map[*fileInfo]struct{}) affectedFiles := make(map[*fileInfo]struct{})
for _, entry := range blobs { for _, entry := range blobs {
@ -261,18 +275,9 @@ func (r *fileRestorer) downloadPack(ctx context.Context, pack *packInfo) error {
return errFile return errFile
} }
} }
}
return nil return nil
} }
func (r *fileRestorer) sanitizeError(file *fileInfo, err error) error {
if err != nil {
err = r.Error(file.location, err)
}
return err
}
func (r *fileRestorer) downloadBlobs(ctx context.Context, packID restic.ID, func (r *fileRestorer) downloadBlobs(ctx context.Context, packID restic.ID,
blobs blobToFileOffsetsMapping, processedBlobs restic.BlobSet) error { blobs blobToFileOffsetsMapping, processedBlobs restic.BlobSet) error {