mirror of
https://gitlab.com/mangadex-pub/mangadex_at_home.git
synced 2024-01-19 02:48:37 +00:00
Clean up some code
This commit is contained in:
parent
0dc62fee66
commit
5628ef7673
|
@ -75,7 +75,7 @@ class MangaDexClient(private val settingsFile: File, databaseFile: File, cacheFo
|
|||
|
||||
database = Database.connect("jdbc:h2:$databaseFile", "org.h2.Driver")
|
||||
storage = ImageStorage(
|
||||
maxSize = (settings.maxCacheSizeInMebibytes * 1024 * 1024), /* MiB to bytes */
|
||||
maxSize = (settings.maxCacheSizeInMebibytes * 1024 * 1024 * 0.95).toLong(), /* MiB to bytes */
|
||||
cacheFolder,
|
||||
database
|
||||
)
|
||||
|
@ -164,7 +164,7 @@ class MangaDexClient(private val settingsFile: File, databaseFile: File, cacheFo
|
|||
}
|
||||
LOGGER.info { "New settings loaded: $newSettings" }
|
||||
|
||||
storage.maxSize = (newSettings.maxCacheSizeInMebibytes * 1024 * 1024 * 0.8).toLong()
|
||||
storage.maxSize = (newSettings.maxCacheSizeInMebibytes * 1024 * 1024 * 0.95).toLong()
|
||||
|
||||
val restartServer = newSettings.serverSettings != settings.serverSettings ||
|
||||
newSettings.devSettings != settings.devSettings ||
|
||||
|
@ -188,9 +188,9 @@ class MangaDexClient(private val settingsFile: File, databaseFile: File, cacheFo
|
|||
}
|
||||
|
||||
private fun validateSettings(settings: ClientSettings) {
|
||||
if (settings.maxCacheSizeInMebibytes < 1024) {
|
||||
throw ClientSettingsException("Config Error: Invalid max cache size, must be >= 1024 MiB (1GiB)")
|
||||
}
|
||||
// if (settings.maxCacheSizeInMebibytes < 1024) {
|
||||
// throw ClientSettingsException("Config Error: Invalid max cache size, must be >= 1024 MiB (1GiB)")
|
||||
// }
|
||||
|
||||
fun isSecretValid(clientSecret: String): Boolean {
|
||||
return Pattern.matches("^[a-zA-Z0-9]{$CLIENT_KEY_LENGTH}$", clientSecret)
|
||||
|
|
|
@ -57,7 +57,6 @@ import java.security.cert.X509Certificate
|
|||
import java.util.concurrent.atomic.AtomicReference
|
||||
import javax.net.ssl.SSLException
|
||||
|
||||
private val LOGGER = LoggerFactory.getLogger("AppNetty")
|
||||
|
||||
class Netty(private val tls: TlsCert, private val serverSettings: ServerSettings, private val statistics: AtomicReference<Statistics>) : ServerConfig {
|
||||
override fun toServer(httpHandler: HttpHandler): Http4kServer = object : Http4kServer {
|
||||
|
@ -142,6 +141,10 @@ class Netty(private val tls: TlsCert, private val serverSettings: ServerSettings
|
|||
|
||||
override fun port(): Int = if (serverSettings.port > 0) serverSettings.port else address.port
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val LOGGER = LoggerFactory.getLogger(Netty::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
fun getX509Certs(certificates: String): Collection<X509Certificate> {
|
||||
|
|
|
@ -24,15 +24,16 @@ import dev.afanasev.sekret.Secret
|
|||
|
||||
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy::class)
|
||||
data class ClientSettings(
|
||||
val maxCacheSizeInMebibytes: Long = 20480,
|
||||
val maxCacheSizeInMebibytes: Long,
|
||||
val serverSettings: ServerSettings,
|
||||
|
||||
val devSettings: DevSettings = DevSettings(),
|
||||
val serverSettings: ServerSettings = ServerSettings(),
|
||||
val metricsSettings: MetricsSettings = MetricsSettings(),
|
||||
)
|
||||
|
||||
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy::class)
|
||||
data class ServerSettings(
|
||||
@field:Secret val secret: String = "PASTE-YOUR-SECRET-HERE",
|
||||
@field:Secret val secret: String,
|
||||
val externalPort: Int = 0,
|
||||
val gracefulShutdownWaitSeconds: Int = 60,
|
||||
val hostname: String = "0.0.0.0",
|
||||
|
|
Loading…
Reference in a new issue