Simplify context cancellation checks

This commit is contained in:
Philipp Wolfer 2025-05-22 14:13:31 +02:00
parent 4a66e3d432
commit 20853f7601
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
5 changed files with 53 additions and 68 deletions

View file

@ -90,13 +90,11 @@ func (b *SpotifyHistoryBackend) ExportListens(ctx context.Context, oldestTimesta
fileCount := int64(len(files))
p.Export.Total = fileCount
for i, filePath := range files {
select {
case <-ctx.Done():
results <- models.ListensResult{Error: ctx.Err()}
if err := ctx.Err(); err != nil {
results <- models.ListensResult{Error: err}
p.Export.Abort()
progress <- p
return
default:
}
history, err := readHistoryFile(filePath)