mirror of
https://github.com/restic/restic.git
synced 2026-10-17 23:18:12 +00:00
Merge pull request #4960 from MichaelEischer/reduce-cancelation-delays
Add more checks for canceled contexts
This commit is contained in:
18 files changed
+105
-11
No files matched your search
@@ -122,6 +122,10 @@ func (r *fileRestorer) restoreFiles(ctx context.Context) error {
|
||||
|
||||
// create packInfo from fileInfo
|
||||
for _, file := range r.files {
|
||||
if ctx.Err() != nil {
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
fileBlobs := file.blobs.(restic.IDs)
|
||||
largeFile := len(fileBlobs) > largeFileBlobCount
|
||||
var packsMap map[restic.ID][]fileBlobInfo
|
||||
|
||||
@@ -450,7 +450,7 @@ func (res *Restorer) RestoreTo(ctx context.Context, dst string) error {
|
||||
},
|
||||
leaveDir: func(node *restic.Node, target, location string, expectedFilenames []string) error {
|
||||
if res.opts.Delete {
|
||||
if err := res.removeUnexpectedFiles(target, location, expectedFilenames); err != nil {
|
||||
if err := res.removeUnexpectedFiles(ctx, target, location, expectedFilenames); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -469,7 +469,7 @@ func (res *Restorer) RestoreTo(ctx context.Context, dst string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (res *Restorer) removeUnexpectedFiles(target, location string, expectedFilenames []string) error {
|
||||
func (res *Restorer) removeUnexpectedFiles(ctx context.Context, target, location string, expectedFilenames []string) error {
|
||||
if !res.opts.Delete {
|
||||
panic("internal error")
|
||||
}
|
||||
@@ -487,6 +487,10 @@ func (res *Restorer) removeUnexpectedFiles(target, location string, expectedFile
|
||||
}
|
||||
|
||||
for _, entry := range entries {
|
||||
if ctx.Err() != nil {
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
if _, ok := keep[toComparableFilename(entry)]; ok {
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user