mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-06-30 09:24:34 -05:00
Fix paths in system properties (#1528)
* Fix paths in system properties * Remove uneeded parse * Cleanup name
This commit is contained in:
@@ -14,7 +14,6 @@ import io.github.config4k.ClassContainer
|
|||||||
import io.github.config4k.TypeReference
|
import io.github.config4k.TypeReference
|
||||||
import io.github.config4k.getValue
|
import io.github.config4k.getValue
|
||||||
import io.github.config4k.readers.SelectReader
|
import io.github.config4k.readers.SelectReader
|
||||||
import io.github.config4k.toConfig
|
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,22 +44,19 @@ class SystemPropertyOverrideDelegate(
|
|||||||
property: KProperty<*>,
|
property: KProperty<*>,
|
||||||
): T {
|
): T {
|
||||||
val config = getConfig()
|
val config = getConfig()
|
||||||
val configValue: T = config.getValue(thisRef, property)
|
|
||||||
|
|
||||||
val combined =
|
val systemProperty =
|
||||||
System.getProperty(
|
System.getProperty("$CONFIG_PREFIX.$moduleName.${property.name}")
|
||||||
"$CONFIG_PREFIX.$moduleName.${property.name}",
|
if (systemProperty == null) {
|
||||||
configValue!!
|
val configValue: T = config.getValue(thisRef, property)
|
||||||
.toConfig("internal")
|
return configValue
|
||||||
.root()
|
}
|
||||||
.render()
|
|
||||||
.removePrefix("internal="),
|
val systemPropertyConfig =
|
||||||
)
|
|
||||||
val combinedConfig =
|
|
||||||
try {
|
try {
|
||||||
ConfigFactory.parseString(combined)
|
ConfigFactory.parseString("internal=$systemProperty")
|
||||||
} catch (_: ConfigException) {
|
} catch (_: ConfigException) {
|
||||||
ConfigFactory.parseString("internal=$combined")
|
ConfigFactory.parseString("internal=\"$systemProperty\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
val genericType = object : TypeReference<T>() {}.genericType()
|
val genericType = object : TypeReference<T>() {}.genericType()
|
||||||
@@ -68,7 +64,7 @@ class SystemPropertyOverrideDelegate(
|
|||||||
val reader = SelectReader.getReader(clazz)
|
val reader = SelectReader.getReader(clazz)
|
||||||
val path = property.name
|
val path = property.name
|
||||||
|
|
||||||
val result = reader(combinedConfig, "internal")
|
val result = reader(systemPropertyConfig, "internal")
|
||||||
return try {
|
return try {
|
||||||
result as T
|
result as T
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|||||||
Reference in New Issue
Block a user