mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-10 06:42:05 +01:00
Fix Tachidesk-Server launch issues crashing the application
This commit is contained in:
@@ -10,7 +10,6 @@ import ca.gosyer.jui.core.io.copyTo
|
||||
import ca.gosyer.jui.core.io.userDataDir
|
||||
import ca.gosyer.jui.core.lang.withIOContext
|
||||
import ca.gosyer.jui.domain.build.BuildKonfig
|
||||
import kotlinx.coroutines.CoroutineExceptionHandler
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -19,9 +18,9 @@ import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.cancelChildren
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.mapLatest
|
||||
import kotlinx.coroutines.withContext
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
import okio.FileSystem
|
||||
import okio.Path
|
||||
@@ -109,13 +108,7 @@ class ServerService @Inject constructor(
|
||||
ServerResult.UNUSED
|
||||
return
|
||||
}
|
||||
val handler = CoroutineExceptionHandler { _, throwable ->
|
||||
log.error(throwable) { "Error launching Tachidesk.jar" }
|
||||
if (_initialized.value == ServerResult.STARTING || _initialized.value == ServerResult.STARTED) {
|
||||
_initialized.value = ServerResult.FAILED
|
||||
}
|
||||
}
|
||||
withContext(handler) {
|
||||
|
||||
val jarFile = userDataDir / "Tachidesk.jar"
|
||||
if (!FileSystem.SYSTEM.exists(jarFile)) {
|
||||
log.info { "Copying server to resources" }
|
||||
@@ -174,7 +167,6 @@ class ServerService @Inject constructor(
|
||||
process = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun startServer() {
|
||||
scope.coroutineContext.cancelChildren()
|
||||
@@ -182,6 +174,12 @@ class ServerService @Inject constructor(
|
||||
.mapLatest {
|
||||
runService()
|
||||
}
|
||||
.catch {
|
||||
log.error(it) { "Error launching Tachidesk.jar" }
|
||||
if (_initialized.value == ServerResult.STARTING || _initialized.value == ServerResult.STARTED) {
|
||||
_initialized.value = ServerResult.FAILED
|
||||
}
|
||||
}
|
||||
.launchIn(scope)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user