Fix loop var in concurrent download

This commit is contained in:
Balakrishnan Balasubramanian 2022-05-13 13:56:34 -04:00
parent 4270b9ae24
commit 472b306dbf

View File

@ -38,7 +38,8 @@ func Run(configPath string) {
tgram := telegram.NewTelegramSender(tgramProxy, cfg.TelegramAuthToken) tgram := telegram.NewTelegramSender(tgramProxy, cfg.TelegramAuthToken)
wg := sync.WaitGroup{} wg := sync.WaitGroup{}
for _, feed := range cfg.Feeds { for i := range cfg.Feeds {
feed := &cfg.Feeds[i]
log.Info("processing feed", "feed", feed.Name) log.Info("processing feed", "feed", feed.Name)
wg.Add(1) wg.Add(1)
go func() { go func() {
@ -49,7 +50,7 @@ func Run(configPath string) {
wg.Wait() wg.Wait()
} }
func ProcessFeed(feed FeedCfg, scheduler Scheduler, dbDir string, tgram telegram.TelegramSender) { func ProcessFeed(feed *FeedCfg, scheduler Scheduler, dbDir string, tgram telegram.TelegramSender) {
sd, err := scheduler.ShouldDownload(feed.Name, feed.Cron) sd, err := scheduler.ShouldDownload(feed.Name, feed.Cron)
if err != nil { if err != nil {
log.Error("shouldDownload failed", "feed", feed.Name, "err", err) log.Error("shouldDownload failed", "feed", feed.Name, "err", err)