From 51cf57400e0d8e3daeb6b28c6354c12dabe158da Mon Sep 17 00:00:00 2001 From: sentriz Date: Wed, 27 Sep 2023 13:51:23 +0100 Subject: [PATCH] don't start purge job if podcast-purge-age-days not set Co-authored-by: Alex McGrath --- cmd/gonic/gonic.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/cmd/gonic/gonic.go b/cmd/gonic/gonic.go index 28fe1746..e081bc62 100644 --- a/cmd/gonic/gonic.go +++ b/cmd/gonic/gonic.go @@ -301,16 +301,18 @@ func main() { return nil }, noCleanup) - g.Add(func() error { - log.Printf("starting job 'podcast purger'\n") - ticker := time.NewTicker(24 * time.Hour) - for range ticker.C { - if err := podcast.PurgeOldPodcasts(time.Duration(*confPodcastPurgeAgeDays) * 24 * time.Hour); err != nil { - log.Printf("error purging old podcasts: %v", err) + if *confPodcastPurgeAgeDays > 0 { + g.Add(func() error { + log.Printf("starting job 'podcast purger'\n") + ticker := time.NewTicker(24 * time.Hour) + for range ticker.C { + if err := podcast.PurgeOldPodcasts(time.Duration(*confPodcastPurgeAgeDays) * 24 * time.Hour); err != nil { + log.Printf("error purging old podcasts: %v", err) + } } - } - return nil - }, noCleanup) + return nil + }, noCleanup) + } if *confScanIntervalMins > 0 { g.Add(func() error {