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

@ -20,17 +20,13 @@ import (
func HandleDownloadRequest(
bot *gotgbot.Bot,
ctx *ext.Context,
taskCtx context.Context,
dlCtx *models.DownloadContext,
) error {
taskCtx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
defer cancel()
dlCtx.Context = taskCtx
chatID := ctx.EffectiveMessage.Chat.Id
if dlCtx.Extractor.Type == enums.ExtractorTypeSingle {
TypingEffect(bot, ctx, chatID)
err := HandleDefaultFormatDownload(bot, ctx, dlCtx)
err := HandleDefaultFormatDownload(bot, ctx, taskCtx, dlCtx)
if err != nil {
return err
}