mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-09 07:18:57 +07:00
Revert "Use kotlin coroutines instead of raw threads (+ refactorings) (#6801)"
This reverts commit f8e0f572
This commit is contained in:
@ -6,7 +6,6 @@ import com.github.ajalt.clikt.parameters.options.option
|
||||
import com.github.ajalt.clikt.parameters.types.int
|
||||
import com.github.ajalt.clikt.parameters.types.restrictTo
|
||||
import io.ktor.application.*
|
||||
import io.ktor.http.*
|
||||
import io.ktor.response.*
|
||||
import io.ktor.routing.*
|
||||
import io.ktor.server.engine.*
|
||||
@ -15,7 +14,6 @@ import io.ktor.utils.io.jvm.javaio.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
import java.io.FileNotFoundException
|
||||
|
||||
|
||||
internal object UncivServer {
|
||||
@ -62,10 +60,7 @@ private class UncivServerRunner : CliktCommand() {
|
||||
val fileName = call.parameters["fileName"] ?: throw Exception("No fileName!")
|
||||
println("Get file: $fileName")
|
||||
val file = File(fileFolderName, fileName)
|
||||
if (!file.exists()) {
|
||||
call.respond(HttpStatusCode.NotFound, "File does not exist")
|
||||
return@get
|
||||
}
|
||||
if (!file.exists()) throw Exception("File does not exist!")
|
||||
val fileText = file.readText()
|
||||
println("Text read: $fileText")
|
||||
call.respondText(fileText)
|
||||
@ -73,10 +68,7 @@ private class UncivServerRunner : CliktCommand() {
|
||||
delete("/files/{fileName}") {
|
||||
val fileName = call.parameters["fileName"] ?: throw Exception("No fileName!")
|
||||
val file = File(fileFolderName, fileName)
|
||||
if (!file.exists()) {
|
||||
call.respond(HttpStatusCode.NotFound, "File does not exist")
|
||||
return@delete
|
||||
}
|
||||
if (!file.exists()) throw Exception("File does not exist!")
|
||||
file.delete()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user