From 7bc3b65b3c66c7744e1c6d4fa69842985d06d9b7 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 5 May 2026 14:24:23 +0300 Subject: Fix podcast support critical bugs from code review - Fix boolean scanning from SQLite INTEGER columns (intToBool helper) - Fix BrowseSet LIMIT 0 returning zero episodes (use 1000 instead) - Fix checkFeed double-fetch by parsing from resp.Body directly + Add ParseFeedReader for body reuse - Fix file handle leak in DownloadEpisode (explicit Close before ImportMediaFile) - Fix incomplete rollback in DownloadEpisode (remove file + delete media row) - Fix 204 No Content handler writing 'null' body - Fix DownloadCoverImage to accept *http.Client with timeout - Deduplicate uniqueFilename into shared internal/service/filename.go - Wire frontend renderPodcastEpisodes into renderBrowse from API data - Refactor podcasts.js: remove extra API call, fix toggle toast, remove duplicate toast - Add Config.PodcastCheckMinutes + PODCAST_CHECK_INTERVAL_MINUTES env var - Start background CheckFeeds goroutine in main.go with ticker - Update NewPodcastService to accept checkInterval parameter - Log errors from CheckFeeds and episode creation instead of silently discarding --- cmd/player/main.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/player/main.go b/cmd/player/main.go index b0fec6c..0a7bacb 100644 --- a/cmd/player/main.go +++ b/cmd/player/main.go @@ -95,11 +95,27 @@ func wireDeps(cfg *internal.Config, store repository.Store, logger *slog.Logger, authSvc := service.NewAuthService(store, clk, hasher, sm) helper := service.NewAccessHelper(store) - podcastSvc := service.NewPodcastService(store, clk, cfg.MediaRoot, helper, prober, thumbGen) + podcastSvc := service.NewPodcastService(store, clk, cfg.MediaRoot, helper, prober, thumbGen, cfg.PodcastCheckMinutes) gcWorker := service.NewGCWorker(store, clk, cfg.MediaRoot, time.Duration(cfg.GCIntervalMinutes)*time.Minute, logger) gcWorker.Start() + // Start podcast feed background checker. + go func() { + ticker := time.NewTicker(time.Duration(cfg.PodcastCheckMinutes) * time.Minute) + defer ticker.Stop() + for { + select { + case <-ticker.C: + if err := podcastSvc.CheckFeeds(context.Background()); err != nil { + logger.Error("podcast feed check failed", "err", err) + } + case <-appCtx.Done(): + return + } + } + }() + return &appDeps{ store: store, hasher: hasher, -- cgit v1.2.3