From 3315758a177614a14b8f3e62b44cde126de7aaa4 Mon Sep 17 00:00:00 2001 From: Akhil Gupta Date: Mon, 22 Feb 2021 12:48:44 +0530 Subject: [PATCH] fix breaking single download --- service/podcastService.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/service/podcastService.go b/service/podcastService.go index d1e5f26..3790275 100644 --- a/service/podcastService.go +++ b/service/podcastService.go @@ -318,12 +318,18 @@ func DownloadMissingImages() error { return err } for _, item := range *items { - downloadImageLocally(item) + downloadImageLocally(item.ID) } return nil } -func downloadImageLocally(podcastItem db.PodcastItem) error { +func downloadImageLocally(podcastItemId string) error { + var podcastItem db.PodcastItem + err := db.GetPodcastItemById(podcastItemId, &podcastItem) + if err != nil { + return err + } + path, err := DownloadImage(podcastItem.Image, podcastItem.ID, podcastItem.Podcast.Title) if err != nil { return err @@ -350,8 +356,10 @@ func SetPodcastItemBookmarkStatus(id string, bookmark bool) error { func SetPodcastItemAsDownloaded(id string, location string) error { var podcastItem db.PodcastItem + err := db.GetPodcastItemById(id, &podcastItem) if err != nil { + fmt.Println("Location", err.Error()) return err } podcastItem.DownloadDate = time.Now() @@ -494,13 +502,17 @@ func DownloadSingleEpisode(podcastItemId string) error { SetPodcastItemAsQueuedForDownload(podcastItemId) url, err := Download(podcastItem.FileURL, podcastItem.Title, podcastItem.Podcast.Title, GetPodcastPrefix(&podcastItem, setting)) + if err != nil { + fmt.Println(err.Error()) return err } + err = SetPodcastItemAsDownloaded(podcastItem.ID, url) + if setting.DownloadEpisodeImages { - go downloadImageLocally(podcastItem) + downloadImageLocally(podcastItem.ID) } - return SetPodcastItemAsDownloaded(podcastItem.ID, url) + return err } func RefreshEpisodes() error {