Update Suwayomi-Server

This commit is contained in:
Syer10
2024-03-28 20:05:43 -04:00
parent 1a71938a44
commit a1361f930c
8 changed files with 35 additions and 31 deletions

View File

@@ -50,7 +50,6 @@ import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapLatest
import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.job
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
import org.lighthousegames.logging.logging
@@ -199,15 +198,16 @@ class AndroidLibraryService : Service() {
private fun onReceived(status: UpdateStatus) {
LibraryUpdateService.updateStatus.value = status
val complete = status.statusMap[JobStatus.COMPLETE]?.size ?: 0
val failed = status.statusMap[JobStatus.FAILED]?.size ?: 0
val running = status.statusMap[JobStatus.RUNNING]?.size ?: 0
val pending = status.statusMap[JobStatus.PENDING]?.size ?: 0
val total = complete + failed + running + pending
val current = complete + failed
val complete = status.mangaStatusMap[JobStatus.COMPLETE]?.size ?: 0
val failed = status.mangaStatusMap[JobStatus.FAILED]?.size ?: 0
val running = status.mangaStatusMap[JobStatus.RUNNING]?.size ?: 0
val pending = status.mangaStatusMap[JobStatus.PENDING]?.size ?: 0
val skipped = status.mangaStatusMap[JobStatus.SKIPPED]?.size ?: 0
val total = complete + failed + running + pending + skipped
val current = complete + failed + skipped
if (current != total) {
val notification = with(progressNotificationBuilder) {
val updatingText = status.statusMap[JobStatus.RUNNING]
val updatingText = status.mangaStatusMap[JobStatus.RUNNING]
?.joinToString("\n") { it.title.chop(40) }
setContentTitle(
MR.strings.notification_updating

View File

@@ -4,11 +4,11 @@ object Config {
const val migrationCode = 4
// Tachidesk-Server version
const val tachideskVersion = "v0.7.0"
const val tachideskVersion = "v1.0.0"
// Match this to the Tachidesk-Server commit count
const val serverCode = 1304
const val preview = true
const val previewCommit = "9a80992aec5edfc5293f1fed79d5e34cad14cb74"
const val serverCode = 1498
const val preview = false
const val previewCommit = "54df9d634a1e83143a6cacf6206b6504721b6ca8"
val desktopJvmTarget = JavaVersion.VERSION_17
val androidJvmTarget = JavaVersion.VERSION_11

View File

@@ -61,17 +61,17 @@ private fun isSigning(properties: Map<String, Any?>) = properties["compose.deskt
private const val tmpPath = "tmp"
private val tarUrl = if (preview) {
"https://github.com/Suwayomi/Tachidesk-Server/archive/$previewCommit.tar.gz"
"https://github.com/Suwayomi/Suwayomi-Server/archive/$previewCommit.tar.gz"
} else {
"https://github.com/Suwayomi/Tachidesk-Server/archive/refs/tags/$tachideskVersion.tar.gz"
"https://github.com/Suwayomi/Suwayomi-Server/archive/refs/tags/$tachideskVersion.tar.gz"
}
private const val tmpTar = "$tmpPath/Tachidesk-Server.tar.gz"
private const val tmpTar = "$tmpPath/Suwayomi-Server.tar.gz"
private val fileSuffix get() = if (preview) {
previewCommit
} else {
tachideskVersion.drop(1)
}
private val tmpServerFolder = "$tmpPath/Tachidesk-Server-$fileSuffix/"
private val tmpServerFolder = "$tmpPath/Suwayomi-Server-$fileSuffix/"
private const val macosFolder = "$tmpPath/macos/"
private const val macosJarFolder = "$tmpPath/macos/jar/"
private const val destination = "src/main/resources/"
@@ -129,8 +129,8 @@ fun TaskContainerScope.registerTachideskTasks(project: Project) {
workingDir(tmpServerFolder)
val os = DefaultNativePlatform.getCurrentOperatingSystem()
when {
os.isWindows -> commandLine("cmd", "/c", "gradlew", ":server:shadowJar", "--no-daemon")
os.isLinux || os.isMacOsX -> commandLine("./gradlew", ":server:shadowJar", "--no-daemon")
os.isWindows -> commandLine("cmd", "/c", "gradlew", ":server:shadowJar", "--no-daemon", "-x", "ktlintFormat")
os.isLinux || os.isMacOsX -> commandLine("./gradlew", ":server:shadowJar", "--no-daemon", "-x", "ktlintFormat")
}
}
register(copyTachideskJarTask) {
@@ -142,7 +142,7 @@ fun TaskContainerScope.registerTachideskTasks(project: Project) {
file("${tmpServerFolder}server/build/").listFiles()
.orEmpty()
.find {
it.nameWithoutExtension.startsWith("Tachidesk-Server-$tachideskVersion-r") &&
it.nameWithoutExtension.startsWith("Suwayomi-Server-$tachideskVersion-r") &&
it.extension == "jar"
}
?.copyTo(file("${destination}Tachidesk.jar"))

View File

@@ -11,9 +11,7 @@ import kotlinx.serialization.Serializable
@Serializable
@Stable
enum class JobStatus {
PENDING,
RUNNING,
COMPLETE,
FAILED,
enum class CategoryUpdateStatus {
UPDATING,
SKIPPED,
}

View File

@@ -16,4 +16,5 @@ enum class JobStatus {
RUNNING,
COMPLETE,
FAILED,
SKIPPED,
}

View File

@@ -7,12 +7,14 @@
package ca.gosyer.jui.domain.library.model
import androidx.compose.runtime.Immutable
import ca.gosyer.jui.domain.category.model.Category
import ca.gosyer.jui.domain.manga.model.Manga
import kotlinx.serialization.Serializable
@Serializable
@Immutable
data class UpdateStatus(
val statusMap: Map<JobStatus, List<Manga>>,
val categoryStatusMap: Map<CategoryUpdateStatus, List<Category>> = emptyMap(),
val mangaStatusMap: Map<JobStatus, List<Manga>> = emptyMap(),
val running: Boolean,
)

View File

@@ -13,7 +13,6 @@ import ca.gosyer.jui.domain.server.service.ServerPreferences
import io.ktor.websocket.Frame
import io.ktor.websocket.readText
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.serialization.decodeFromString
import me.tatarka.inject.annotations.Inject
import org.lighthousegames.logging.logging
@@ -37,6 +36,6 @@ class LibraryUpdateService
private val log = logging()
val status = MutableStateFlow(Status.STARTING)
val updateStatus = MutableStateFlow(UpdateStatus(emptyMap(), false))
val updateStatus = MutableStateFlow(UpdateStatus(emptyMap(), emptyMap(), false))
}
}

View File

@@ -39,13 +39,17 @@ fun LibraryUpdatesExtraInfo() {
fun Map<JobStatus, List<*>>.getSize(jobStatus: JobStatus): Int = get(jobStatus)?.size ?: 0
val current = remember(updateStatus) {
updateStatus.statusMap.run {
getSize(JobStatus.COMPLETE) + getSize(JobStatus.FAILED)
updateStatus.mangaStatusMap.run {
getSize(JobStatus.COMPLETE) + getSize(JobStatus.FAILED) + getSize(JobStatus.SKIPPED)
}
}
val total = remember(updateStatus) {
updateStatus.statusMap.run {
getSize(JobStatus.COMPLETE) + getSize(JobStatus.FAILED) + getSize(JobStatus.PENDING) + getSize(JobStatus.RUNNING)
updateStatus.mangaStatusMap.run {
getSize(JobStatus.COMPLETE) +
getSize(JobStatus.FAILED) +
getSize(JobStatus.PENDING) +
getSize(JobStatus.RUNNING) +
getSize(JobStatus.SKIPPED)
}
}