mirror of
https://github.com/octoleo/restic.git
synced 2024-11-25 06:07:44 +00:00
restore: split error reporting from downloadPack
This commit is contained in:
parent
00d18b7a88
commit
2267910418
@ -244,26 +244,7 @@ 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)
|
||||||
|
|
||||||
if err != nil {
|
return r.reportError(blobs, processedBlobs, err)
|
||||||
// only report error for not yet processed blobs
|
|
||||||
affectedFiles := make(map[*fileInfo]struct{})
|
|
||||||
for _, entry := range blobs {
|
|
||||||
if processedBlobs.Has(entry.blob.BlobHandle) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
for file := range entry.files {
|
|
||||||
affectedFiles[file] = struct{}{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for file := range affectedFiles {
|
|
||||||
if errFile := r.sanitizeError(file, err); errFile != nil {
|
|
||||||
return errFile
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *fileRestorer) sanitizeError(file *fileInfo, err error) error {
|
func (r *fileRestorer) sanitizeError(file *fileInfo, err error) error {
|
||||||
@ -273,6 +254,30 @@ func (r *fileRestorer) sanitizeError(file *fileInfo, err error) error {
|
|||||||
return 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
|
||||||
|
affectedFiles := make(map[*fileInfo]struct{})
|
||||||
|
for _, entry := range blobs {
|
||||||
|
if processedBlobs.Has(entry.blob.BlobHandle) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for file := range entry.files {
|
||||||
|
affectedFiles[file] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for file := range affectedFiles {
|
||||||
|
if errFile := r.sanitizeError(file, err); errFile != nil {
|
||||||
|
return errFile
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
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 {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user