From a14677155bed140053eb88313c2f7dc3812d498f Mon Sep 17 00:00:00 2001 From: RemixDev Date: Sat, 19 Jun 2021 12:03:18 +0200 Subject: [PATCH] Fix concurrency issues when downloading covers --- deemix/downloader.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/deemix/downloader.js b/deemix/downloader.js index 1b13bdb..71082af 100644 --- a/deemix/downloader.js +++ b/deemix/downloader.js @@ -161,6 +161,8 @@ class Downloader { this.extrasPath = null this.playlistCovername = null this.playlistURLs = [] + + this.coverQueue = {} } log(data, state){ @@ -311,7 +313,10 @@ class Downloader { // Download and cache the coverart this.log(itemData, "getAlbumArt") - track.album.embeddedCoverPath = await downloadImage(track.album.embeddedCoverURL, track.album.embeddedCoverPath) + if (!this.coverQueue[track.album.embeddedCoverPath]) + this.coverQueue[track.album.embeddedCoverPath] = downloadImage(track.album.embeddedCoverURL, track.album.embeddedCoverPath) + track.album.embeddedCoverPath = await this.coverQueue[track.album.embeddedCoverPath] + if (this.coverQueue[track.album.embeddedCoverPath]) delete this.coverQueue[track.album.embeddedCoverPath] this.log(itemData, "gotAlbumArt") // Save local album art