From dcccab2489b871070ab3aec033a61016f2748744 Mon Sep 17 00:00:00 2001 From: Zibbp Date: Wed, 7 Aug 2024 23:53:20 +0000 Subject: [PATCH] do not download chat if queue doesn't request it --- internal/tasks/common.go | 15 +++++++++------ internal/tasks/live_video.go | 19 +++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/internal/tasks/common.go b/internal/tasks/common.go index 00bc537..14651b6 100644 --- a/internal/tasks/common.go +++ b/internal/tasks/common.go @@ -374,12 +374,15 @@ func (w DownloadTumbnailsWorker) Work(ctx context.Context, job *river.Job[Downlo return err } - _, err = client.Insert(ctx, &DownloadChatArgs{ - Continue: true, - Input: job.Args.Input, - }, nil) - if err != nil { - return err + // download chat if needed + if dbItems.Queue.ArchiveChat { + _, err = client.Insert(ctx, &DownloadChatArgs{ + Continue: true, + Input: job.Args.Input, + }, nil) + if err != nil { + return err + } } } } diff --git a/internal/tasks/live_video.go b/internal/tasks/live_video.go index 0773aa7..f6dc86b 100644 --- a/internal/tasks/live_video.go +++ b/internal/tasks/live_video.go @@ -73,14 +73,17 @@ func (w DownloadLiveVideoWorker) Work(ctx context.Context, job *river.Job[Downlo for { select { case <-startChatDownload: - log.Debug().Str("channel", dbItems.Channel.Name).Msgf("starting chat download for %s", dbItems.Video.ExtID) - client := river.ClientFromContext[pgx.Tx](ctx) - _, err = client.Insert(ctx, &DownloadLiveChatArgs{ - Continue: true, - Input: job.Args.Input, - }, nil) - if err != nil { - log.Error().Err(err).Msg("failed to start chat download") + // start chat download if requested + if dbItems.Queue.ArchiveChat { + log.Debug().Str("channel", dbItems.Channel.Name).Msgf("starting chat download for %s", dbItems.Video.ExtID) + client := river.ClientFromContext[pgx.Tx](ctx) + _, err = client.Insert(ctx, &DownloadLiveChatArgs{ + Continue: true, + Input: job.Args.Input, + }, nil) + if err != nil { + log.Error().Err(err).Msg("failed to start chat download") + } } case <-ctx.Done(): return