use ctx with cancel to (hopefully) avoid deadlocks

This commit is contained in:
stefanodvx 2025-04-15 17:51:06 +02:00
parent 8d972ff74b
commit 1a27103347
6 changed files with 50 additions and 30 deletions

View file

@ -1,6 +1,7 @@
package core
import (
"context"
"fmt"
"govd/database"
"govd/models"
@ -12,6 +13,7 @@ import (
func HandleDefaultFormatDownload(
bot *gotgbot.Bot,
ctx *ext.Context,
taskCtx context.Context,
dlCtx *models.DownloadContext,
) error {
storedMedias, err := database.GetDefaultMedias(
@ -51,7 +53,7 @@ func HandleDefaultFormatDownload(
mediaList[i].Format = defaultFormat
}
medias, err := DownloadMedias(mediaList, nil)
medias, err := DownloadMedias(taskCtx, mediaList, nil)
if err != nil {
return fmt.Errorf("failed to download media list: %w", err)
}