From c77b2d5ca20a7b49c7302d62a5970a720a7696bf Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Fri, 12 Jul 2024 22:29:56 +0200 Subject: [PATCH] restore: avoid long cancelation delay for frequently used blobs --- internal/restorer/filerestorer.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/restorer/filerestorer.go b/internal/restorer/filerestorer.go index fec8c8780..01d3e43f7 100644 --- a/internal/restorer/filerestorer.go +++ b/internal/restorer/filerestorer.go @@ -327,6 +327,11 @@ func (r *fileRestorer) downloadBlobs(ctx context.Context, packID restic.ID, } for file, offsets := range blob.files { for _, offset := range offsets { + // avoid long cancelation delays for frequently used blobs + if ctx.Err() != nil { + return ctx.Err() + } + writeToFile := func() error { // this looks overly complicated and needs explanation // two competing requirements: