This commit is contained in:
Mitchell Syer
2022-10-22 08:08:14 -04:00
committed by GitHub
parent 3bef07eeab
commit a3c366c360
54 changed files with 159 additions and 109 deletions

View File

@@ -49,7 +49,8 @@ object DownloadManager {
|Supported commands are:
| - STATUS
| sends the current download status
|""".trimMargin()
|
""".trimMargin()
)
}
}
@@ -65,7 +66,11 @@ object DownloadManager {
return DownloadStatus(
if (downloader == null ||
downloadQueue.none { it.state == Downloading }
) "Stopped" else "Started",
) {
"Stopped"
} else {
"Started"
},
downloadQueue
)
}
@@ -96,8 +101,10 @@ object DownloadManager {
}
fun start() {
if (downloader != null && !downloader?.isAlive!!) // doesn't exist or is dead
if (downloader != null && !downloader?.isAlive!!) {
// doesn't exist or is dead
downloader = null
}
if (downloader == null) {
downloader = Downloader(downloadQueue) { notifyAllClients() }
@@ -127,5 +134,5 @@ object DownloadManager {
enum class DownloaderState(val state: Int) {
Stopped(0),
Running(1),
Paused(2),
Paused(2)
}

View File

@@ -18,5 +18,5 @@ class DownloadChapter(
var manga: MangaDataClass,
var state: DownloadState = Queued,
var progress: Float = 0f,
var tries: Int = 0,
var tries: Int = 0
)

View File

@@ -11,5 +11,5 @@ enum class DownloadState(val state: Int) {
Queued(0),
Downloading(1),
Finished(2),
Error(3),
Error(3)
}

View File

@@ -9,5 +9,5 @@ package suwayomi.tachidesk.manga.impl.download.model
data class DownloadStatus(
val status: String,
val queue: List<DownloadChapter>,
val queue: List<DownloadChapter>
)