From 33fea67a446322187446c75398cd3b89e70d328c Mon Sep 17 00:00:00 2001 From: carbotaniuman <41451839+carbotaniuman@users.noreply.github.com> Date: Wed, 5 Aug 2020 10:18:07 -0500 Subject: [PATCH] Fix reload settings to affect cache too --- src/main/kotlin/mdnet/base/MangaDexClient.kt | 24 +++++++------------ .../mdnet/base/settings/ClientSettings.kt | 1 - 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/main/kotlin/mdnet/base/MangaDexClient.kt b/src/main/kotlin/mdnet/base/MangaDexClient.kt index 9a8f93f..32540e6 100644 --- a/src/main/kotlin/mdnet/base/MangaDexClient.kt +++ b/src/main/kotlin/mdnet/base/MangaDexClient.kt @@ -383,6 +383,8 @@ class MangaDexClient(private val clientSettingsFile: String) { return } + cache.maxSize = newSettings.maxCacheSizeInMebibytes + // Setting loaded without issue. Figure out // if there are changes that require a restart val restartServer = newSettings.clientSecret != state.clientSettings.clientSecret || @@ -415,14 +417,6 @@ class MangaDexClient(private val clientSettingsFile: String) { LOGGER.info { "Starting Server after reloading ClientSettings" } loginAndStartServer() - - // Start the WebUI if we had to stop it - // and still want it - if (startWebUi) { - LOGGER.info { "Starting WebUI after reloading ClientSettings" } - startWebUi() - LOGGER.info { "Started WebUI after reloading ClientSettings" } - } }) } else { // If we aren't restarting the server @@ -430,14 +424,14 @@ class MangaDexClient(private val clientSettingsFile: String) { this.state = state.copy(clientSettings = newSettings) serverHandler.settings = newSettings LOGGER.info { "Reloaded ClientSettings: $newSettings" } + } - // Start the WebUI if we had to stop it - // and still want it - if (startWebUi) { - LOGGER.info { "Starting WebUI after reloading ClientSettings" } - startWebUi() - LOGGER.info { "Started WebUI after reloading ClientSettings" } - } + // Start the WebUI if we had to stop it + // and still want it + if (startWebUi) { + LOGGER.info { "Starting WebUI after reloading ClientSettings" } + startWebUi() + LOGGER.info { "Started WebUI after reloading ClientSettings" } } } catch (e: UnrecognizedPropertyException) { LOGGER.warn { "Settings file is invalid: '$e.propertyName' is not a valid setting" } diff --git a/src/main/kotlin/mdnet/base/settings/ClientSettings.kt b/src/main/kotlin/mdnet/base/settings/ClientSettings.kt index f9254be..01a4666 100644 --- a/src/main/kotlin/mdnet/base/settings/ClientSettings.kt +++ b/src/main/kotlin/mdnet/base/settings/ClientSettings.kt @@ -22,7 +22,6 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategy import com.fasterxml.jackson.databind.annotation.JsonNaming import dev.afanasev.sekret.Secret -// client settings are verified correct in Main.kt @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy::class) data class ClientSettings( val maxCacheSizeInMebibytes: Long = 20480,