mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2026-01-06 03:42:33 +01:00
Support having no Tachidesk jar available
This commit is contained in:
@@ -43,12 +43,12 @@ class ServerService @Inject constructor(
|
||||
initialized.value = ServerResult.UNUSED
|
||||
}
|
||||
|
||||
private fun copyJar(jarFile: File) {
|
||||
javaClass.getResourceAsStream("/Tachidesk.jar")?.buffered()?.use { input ->
|
||||
private fun copyJar(jarFile: File): Boolean {
|
||||
return javaClass.getResourceAsStream("/Tachidesk.jar")?.buffered()?.use { input ->
|
||||
jarFile.outputStream().use { output ->
|
||||
input.copyTo(output)
|
||||
}
|
||||
}
|
||||
}?.let { true } ?: false
|
||||
}
|
||||
|
||||
init {
|
||||
@@ -71,7 +71,9 @@ class ServerService @Inject constructor(
|
||||
val jarFile = File(userDataDir, "Tachidesk.jar")
|
||||
if (!jarFile.exists()) {
|
||||
info { "Copying server to resources" }
|
||||
copyJar(jarFile)
|
||||
if (!copyJar(jarFile)) {
|
||||
initialized.value = ServerResult.NO_TACHIDESK_JAR
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
val jarVersion = withIOContext {
|
||||
@@ -131,6 +133,7 @@ class ServerService @Inject constructor(
|
||||
|
||||
enum class ServerResult {
|
||||
UNUSED,
|
||||
NO_TACHIDESK_JAR,
|
||||
STARTING,
|
||||
STARTED,
|
||||
FAILED;
|
||||
|
||||
@@ -126,10 +126,14 @@ fun main() {
|
||||
ServerResult.STARTED, ServerResult.UNUSED -> {
|
||||
MainMenu(rootBundle)
|
||||
}
|
||||
ServerResult.STARTING, ServerResult.FAILED -> {
|
||||
ServerResult.STARTING, ServerResult.FAILED, ServerResult.NO_TACHIDESK_JAR -> {
|
||||
LoadingScreen(
|
||||
initialized == ServerResult.STARTING,
|
||||
errorMessage = "Unable to start server",
|
||||
errorMessage = if (initialized == ServerResult.NO_TACHIDESK_JAR) {
|
||||
"Tachidesk jar does not exist, run Tachidesk yourself"
|
||||
} else {
|
||||
"Unable to start server"
|
||||
},
|
||||
retryMessage = "Start anyway",
|
||||
retry = serverService::startAnyway
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user