diff --git a/server/managers/PodcastManager.js b/server/managers/PodcastManager.js index 11e231dd..5ed0fb89 100644 --- a/server/managers/PodcastManager.js +++ b/server/managers/PodcastManager.js @@ -72,6 +72,15 @@ class PodcastManager { */ async startPodcastEpisodeDownload(podcastEpisodeDownload) { if (this.currentDownload) { + // Prevent downloading episodes from the same URL for the same library item. + // Allow downloading for different library items in case of the same podcast existing in multiple libraries (e.g. different folders) + if (this.downloadQueue.some((d) => d.url === podcastEpisodeDownload.url && d.libraryItem.id === podcastEpisodeDownload.libraryItem.id)) { + Logger.warn(`[PodcastManager] Episode already in queue: "${this.currentDownload.episodeTitle}"`) + return + } else if (this.currentDownload.url === podcastEpisodeDownload.url && this.currentDownload.libraryItem.id === podcastEpisodeDownload.libraryItem.id) { + Logger.warn(`[PodcastManager] Episode download already in progress for "${podcastEpisodeDownload.episodeTitle}"`) + return + } this.downloadQueue.push(podcastEpisodeDownload) SocketAuthority.emitter('episode_download_queued', podcastEpisodeDownload.toJSONForClient()) return