From 611bc96e29abd69e322b0a33705c164b1577dd99 Mon Sep 17 00:00:00 2001 From: sentriz Date: Wed, 20 Apr 2022 23:07:12 +0100 Subject: [PATCH] fix(podcast): add error case for when DownloadEpisode is called via API and podcast is already downloaded closes: #213 Co-authored-by: Brian Doherty --- podcasts/podcasts.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/podcasts/podcasts.go b/podcasts/podcasts.go index 75158fcd..523553b7 100644 --- a/podcasts/podcasts.go +++ b/podcasts/podcasts.go @@ -18,9 +18,9 @@ import ( "github.com/jinzhu/gorm" "github.com/mmcdole/gofeed" - "go.senan.xyz/gonic/multierr" "go.senan.xyz/gonic/db" gmime "go.senan.xyz/gonic/mime" + "go.senan.xyz/gonic/multierr" "go.senan.xyz/gonic/scanner/tags" ) @@ -354,8 +354,8 @@ func (p *Podcasts) DownloadEpisode(episodeID int) error { if err != nil { return fmt.Errorf("get podcast by id: %w", err) } - if podcastEpisode.Status == db.PodcastEpisodeStatusDownloading { - log.Printf("Already downloading podcast episode with id %d", episodeID) + if podcastEpisode.Status == db.PodcastEpisodeStatusDownloading || podcastEpisode.Status == db.PodcastEpisodeStatusCompleted { + log.Printf("already downloading podcast episode with id %d", episodeID) return nil } podcastEpisode.Status = db.PodcastEpisodeStatusDownloading