Skip to content

Commit

Permalink
Fix self update loop
Browse files Browse the repository at this point in the history
  • Loading branch information
mxpv committed Apr 19, 2020
1 parent 57d84f7 commit df7dc56
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/ytdl/ytdl.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@ func New(ctx context.Context, update bool) (*YoutubeDl, error) {
}

if update {
// Do initial update at launch
// Do initial blocking update at launch
if err := ytdl.Update(ctx); err != nil {
log.WithError(err).Error("failed to update youtube-dl")
}

go func() {
for range time.After(UpdatePeriod) {
for {
time.Sleep(UpdatePeriod)

if err := ytdl.Update(context.Background()); err != nil {
log.WithError(err).Error("update failed")
}
Expand Down

0 comments on commit df7dc56

Please sign in to comment.