From 37eeef06e2a5b48e8c2c12d3d24e14264191945c Mon Sep 17 00:00:00 2001 From: Aria Moradi Date: Fri, 4 Jun 2021 16:34:19 +0430 Subject: [PATCH] correct spelling --- .../tachidesk/server/util/AppMutex.kt | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/util/AppMutex.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/util/AppMutex.kt index f2fab27..f8b33ed 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/util/AppMutex.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/util/AppMutex.kt @@ -13,9 +13,6 @@ import okhttp3.OkHttpClient import okhttp3.Request.Builder import suwayomi.tachidesk.server.impl.AboutDataClass import suwayomi.tachidesk.server.serverConfig -import suwayomi.tachidesk.server.util.AppMutex.AppMutexStat.Clear -import suwayomi.tachidesk.server.util.AppMutex.AppMutexStat.OtherApplicationRunning -import suwayomi.tachidesk.server.util.AppMutex.AppMutexStat.TachideskInstanceRunning import suwayomi.tachidesk.server.util.Browser.openInBrowser import suwayomi.tachidesk.server.util.ExitCode.MutexCheckFailedAnotherAppRunning import suwayomi.tachidesk.server.util.ExitCode.MutexCheckFailedTachideskRunning @@ -25,7 +22,7 @@ import java.util.concurrent.TimeUnit object AppMutex { private val logger = KotlinLogging.logger {} - private enum class AppMutexStat(val stat: Int) { + private enum class AppMutexState(val stat: Int) { Clear(0), TachideskInstanceRunning(1), OtherApplicationRunning(2) @@ -33,7 +30,7 @@ object AppMutex { private val appIP = if (serverConfig.ip == "0.0.0.0") "127.0.0.1" else serverConfig.ip - private fun checkAppMutex(): AppMutexStat { + private fun checkAppMutex(): AppMutexState { val client = OkHttpClient.Builder() .connectTimeout(200, TimeUnit.MILLISECONDS) .build() @@ -45,23 +42,23 @@ object AppMutex { val response = try { client.newCall(request).execute().use { response -> response.body!!.string() } } catch (e: IOException) { - return AppMutexStat.Clear + return AppMutexState.Clear } return try { JavalinJackson.fromJson(response, AboutDataClass::class.java) - AppMutexStat.TachideskInstanceRunning + AppMutexState.TachideskInstanceRunning } catch (e: IOException) { - AppMutexStat.OtherApplicationRunning + AppMutexState.OtherApplicationRunning } } fun handleAppMutex() { when (checkAppMutex()) { - Clear -> { + AppMutexState.Clear -> { logger.info("Mutex status is clear, Resuming startup.") } - TachideskInstanceRunning -> { + AppMutexState.TachideskInstanceRunning -> { logger.info("Another instance of Tachidesk is running on $appIP:${serverConfig.port}") logger.info("Probably user thought tachidesk is closed so, opening webUI in browser again.") @@ -71,7 +68,7 @@ object AppMutex { shutdownApp(MutexCheckFailedTachideskRunning) } - OtherApplicationRunning -> { + AppMutexState.OtherApplicationRunning -> { logger.error("A non Tachidesk application is running on $appIP:${serverConfig.port}, aborting startup.") shutdownApp(MutexCheckFailedAnotherAppRunning) }