mirror of
https://git.sr.ht/~phw/scotty
synced 2025-06-05 04:58:33 +02:00
Simplify context cancellation checks
This commit is contained in:
parent
4a66e3d432
commit
20853f7601
5 changed files with 53 additions and 68 deletions
|
@ -106,21 +106,20 @@ func process[R models.LovesResult | models.ListensResult, P ImportProcessor[R]](
|
|||
}
|
||||
|
||||
for exportResult := range results {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
if err := ctx.Err(); err != nil {
|
||||
processor.ImportBackend().FinishImport()
|
||||
out <- handleError(result, ctx.Err(), progress)
|
||||
out <- handleError(result, err, progress)
|
||||
return
|
||||
default:
|
||||
importResult, err := processor.Import(ctx, exportResult, result, out, progress)
|
||||
result.Update(importResult)
|
||||
if err != nil {
|
||||
processor.ImportBackend().FinishImport()
|
||||
out <- handleError(result, err, progress)
|
||||
return
|
||||
}
|
||||
progress <- p.FromImportResult(result, false)
|
||||
}
|
||||
|
||||
importResult, err := processor.Import(ctx, exportResult, result, out, progress)
|
||||
result.Update(importResult)
|
||||
if err != nil {
|
||||
processor.ImportBackend().FinishImport()
|
||||
out <- handleError(result, err, progress)
|
||||
return
|
||||
}
|
||||
progress <- p.FromImportResult(result, false)
|
||||
}
|
||||
|
||||
if err := processor.ImportBackend().FinishImport(); err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue