Fix one crash

This commit is contained in:
tzugen 2022-11-10 11:44:08 +01:00
parent 27b9b0c743
commit 84daba3771
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930

View File

@ -136,7 +136,9 @@ class DownloadService : Service(), KoinComponent {
// Fill up active List with waiting tasks
while (activelyDownloading.size < Settings.parallelDownloads && downloadQueue.size > 0) {
val track = downloadQueue.remove()
// Use poll() instead of remove() which throws an Exception if there is no element.
val track: DownloadableTrack = downloadQueue.poll() ?: continue
val downloadTask = DownloadTask(track, scope!!, ::downloadStateChangedCallback)
activelyDownloading[track] = downloadTask
FileUtil.createDirectoryForParent(track.pinnedFile)