Make web service clients context aware

This commit is contained in:
Philipp Wolfer 2025-05-22 09:22:05 +02:00
parent adfe3f5771
commit d1642b7f1f
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
15 changed files with 128 additions and 76 deletions

View file

@ -17,6 +17,7 @@ Scotty. If not, see <https://www.gnu.org/licenses/>.
package funkwhale
import (
"context"
"sort"
"time"
@ -61,6 +62,7 @@ func (b *FunkwhaleApiBackend) InitConfig(config *config.ServiceConfig) error {
}
func (b *FunkwhaleApiBackend) ExportListens(oldestTimestamp time.Time, results chan models.ListensResult, progress chan models.TransferProgress) {
ctx := context.TODO()
page := 1
perPage := MaxItemsPerGet
@ -74,7 +76,7 @@ func (b *FunkwhaleApiBackend) ExportListens(oldestTimestamp time.Time, results c
out:
for {
result, err := b.client.GetHistoryListenings(b.username, page, perPage)
result, err := b.client.GetHistoryListenings(ctx, b.username, page, perPage)
if err != nil {
p.Export.Abort()
progress <- p
@ -118,6 +120,7 @@ out:
}
func (b *FunkwhaleApiBackend) ExportLoves(oldestTimestamp time.Time, results chan models.LovesResult, progress chan models.TransferProgress) {
ctx := context.TODO()
page := 1
perPage := MaxItemsPerGet
@ -131,7 +134,7 @@ func (b *FunkwhaleApiBackend) ExportLoves(oldestTimestamp time.Time, results cha
out:
for {
result, err := b.client.GetFavoriteTracks(page, perPage)
result, err := b.client.GetFavoriteTracks(ctx, page, perPage)
if err != nil {
p.Export.Abort()
progress <- p