Skip to content

Commit

Permalink
Respect page_size parameter when downloading episodes
Browse files Browse the repository at this point in the history
  • Loading branch information
mxpv committed Apr 16, 2020
1 parent 174557e commit 40dd2f5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/podsync/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,11 @@ func (u *Updater) downloadEpisodes(ctx context.Context, feedConfig *config.Feed)
var (
feedID = feedConfig.ID
downloadList []*model.Episode
pageSize = feedConfig.PageSize
)

log.WithField("page_size", pageSize).Info("downloading episodes")

// Build the list of files to download
if err := u.db.WalkEpisodes(ctx, feedID, func(episode *model.Episode) error {
if episode.Status != model.EpisodeNew && episode.Status != model.EpisodeError {
Expand All @@ -126,6 +129,13 @@ func (u *Updater) downloadEpisodes(ctx context.Context, feedConfig *config.Feed)
}
}

// Limit the number of episodes downloaded at once
pageSize--
if pageSize <= 0 {
return nil
}

log.Debugf("adding %s (%q) to the list", episode.ID, episode.Title)
downloadList = append(downloadList, episode)
return nil
}); err != nil {
Expand Down

0 comments on commit 40dd2f5

Please sign in to comment.