mirror of
https://github.com/Suwayomi/Tachidesk.git
synced 2026-01-06 03:42:34 +01:00
Fix/gql download subscription (#1137)
* Properly set download update type on exceptions
* Always send FINISHED download update to client for deprecated subscription
By the time the status was sent to the client, the finished download item was already removed from the queue, causing the client to never get the latest status, thus, having an outdated cache
Regression introduced with 168b76cb0c
This commit is contained in:
@@ -30,7 +30,9 @@ import suwayomi.tachidesk.manga.impl.download.model.DownloadState.Queued
|
||||
import suwayomi.tachidesk.manga.impl.download.model.DownloadUpdate
|
||||
import suwayomi.tachidesk.manga.impl.download.model.DownloadUpdateType.ERROR
|
||||
import suwayomi.tachidesk.manga.impl.download.model.DownloadUpdateType.FINISHED
|
||||
import suwayomi.tachidesk.manga.impl.download.model.DownloadUpdateType.PAUSED
|
||||
import suwayomi.tachidesk.manga.impl.download.model.DownloadUpdateType.PROGRESS
|
||||
import suwayomi.tachidesk.manga.impl.download.model.DownloadUpdateType.STOPPED
|
||||
import suwayomi.tachidesk.manga.model.table.ChapterTable
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
|
||||
@@ -99,8 +101,8 @@ class Downloader(
|
||||
logger: KLogger,
|
||||
download: DownloadChapter,
|
||||
) {
|
||||
downloadQueue -= download
|
||||
notifier(true, DownloadUpdate(FINISHED, download))
|
||||
downloadQueue -= download
|
||||
onDownloadFinished()
|
||||
logger.debug { "finished" }
|
||||
}
|
||||
@@ -146,14 +148,15 @@ class Downloader(
|
||||
} catch (e: CancellationException) {
|
||||
logger.debug("Downloader was stopped")
|
||||
availableSourceDownloads.filter { it.state == Downloading }.forEach { it.state = Queued }
|
||||
notifier(false, DownloadUpdate(STOPPED, download))
|
||||
} catch (e: PauseDownloadException) {
|
||||
downloadLogger.debug { "paused" }
|
||||
download.state = Queued
|
||||
notifier(false, DownloadUpdate(PAUSED, download))
|
||||
} catch (e: Exception) {
|
||||
downloadLogger.warn("failed due to", e)
|
||||
download.tries++
|
||||
download.state = Error
|
||||
} finally {
|
||||
notifier(false, DownloadUpdate(ERROR, download))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package suwayomi.tachidesk.manga.impl.download.model
|
||||
enum class DownloadUpdateType {
|
||||
QUEUED,
|
||||
DEQUEUED,
|
||||
PAUSED,
|
||||
STOPPED,
|
||||
PROGRESS,
|
||||
FINISHED,
|
||||
ERROR,
|
||||
|
||||
Reference in New Issue
Block a user