mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-03-01 00:15:54 +01:00
Add: prevent duplicates from being added to queue
This commit is contained in:
parent
c7d8021a16
commit
6674189acd
@ -72,6 +72,15 @@ class PodcastManager {
|
|||||||
*/
|
*/
|
||||||
async startPodcastEpisodeDownload(podcastEpisodeDownload) {
|
async startPodcastEpisodeDownload(podcastEpisodeDownload) {
|
||||||
if (this.currentDownload) {
|
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)
|
this.downloadQueue.push(podcastEpisodeDownload)
|
||||||
SocketAuthority.emitter('episode_download_queued', podcastEpisodeDownload.toJSONForClient())
|
SocketAuthority.emitter('episode_download_queued', podcastEpisodeDownload.toJSONForClient())
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user