fix(podcast): add error case for when DownloadEpisode is called via API and podcast is already downloaded

closes: #213

Co-authored-by: Brian Doherty <brian.r.doherty@gmail.com>
This commit is contained in:
sentriz
2022-04-20 23:07:12 +01:00
parent 8b803ecf20
commit 611bc96e29

View File

@@ -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