Skip to content

Commit

Permalink
Update Suwayomi-Server
Browse files Browse the repository at this point in the history
  • Loading branch information
Syer10 committed Mar 29, 2024
1 parent 1a71938 commit a1361f9
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions buildSrc/src/main/kotlin/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions buildSrc/src/main/kotlin/TachideskTasks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down Expand Up @@ -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) {
Expand All @@ -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"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import kotlinx.serialization.Serializable

@Serializable
@Stable
enum class JobStatus {
PENDING,
RUNNING,
COMPLETE,
FAILED,
enum class CategoryUpdateStatus {
UPDATING,
SKIPPED,
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ enum class JobStatus {
RUNNING,
COMPLETE,
FAILED,
SKIPPED,
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit a1361f9

Please sign in to comment.