Skip to content

Commit

Permalink
do not download chat if queue doesn't request it
Browse files Browse the repository at this point in the history
  • Loading branch information
Zibbp committed Aug 7, 2024
1 parent 4614c88 commit dcccab2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
15 changes: 9 additions & 6 deletions internal/tasks/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
Expand Down
19 changes: 11 additions & 8 deletions internal/tasks/live_video.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dcccab2

Please sign in to comment.