mirror of
https://github.com/Suwayomi/Tachidesk.git
synced 2026-01-25 21:14:06 +01:00
Feature/make config settings changeable during runtime (#545)
* Add logic to update config during runtime * Update ConfigModule to always use the latest config * Make ServerConfig settings re-assignable
This commit is contained in:
@@ -8,12 +8,12 @@ import xyz.nulldev.ts.config.ConfigModule
|
||||
* Application info config.
|
||||
*/
|
||||
|
||||
class ApplicationInfoConfigModule(config: Config) : ConfigModule(config) {
|
||||
val packageName: String by config
|
||||
val debug: Boolean by config
|
||||
class ApplicationInfoConfigModule(getConfig: () -> Config) : ConfigModule(getConfig) {
|
||||
val packageName: String by getConfig()
|
||||
val debug: Boolean by getConfig()
|
||||
|
||||
companion object {
|
||||
fun register(config: Config) =
|
||||
ApplicationInfoConfigModule(config.getConfig("android.app"))
|
||||
ApplicationInfoConfigModule { config.getConfig("android.app") }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,27 +8,27 @@ import xyz.nulldev.ts.config.ConfigModule
|
||||
* Files configuration modules. Specifies where to store the Android files.
|
||||
*/
|
||||
|
||||
class FilesConfigModule(config: Config) : ConfigModule(config) {
|
||||
val dataDir: String by config
|
||||
val filesDir: String by config
|
||||
val noBackupFilesDir: String by config
|
||||
val externalFilesDirs: MutableList<String> by config
|
||||
val obbDirs: MutableList<String> by config
|
||||
val cacheDir: String by config
|
||||
val codeCacheDir: String by config
|
||||
val externalCacheDirs: MutableList<String> by config
|
||||
val externalMediaDirs: MutableList<String> by config
|
||||
val rootDir: String by config
|
||||
val externalStorageDir: String by config
|
||||
val downloadCacheDir: String by config
|
||||
val databasesDir: String by config
|
||||
class FilesConfigModule(getConfig: () -> Config) : ConfigModule(getConfig) {
|
||||
val dataDir: String by getConfig()
|
||||
val filesDir: String by getConfig()
|
||||
val noBackupFilesDir: String by getConfig()
|
||||
val externalFilesDirs: MutableList<String> by getConfig()
|
||||
val obbDirs: MutableList<String> by getConfig()
|
||||
val cacheDir: String by getConfig()
|
||||
val codeCacheDir: String by getConfig()
|
||||
val externalCacheDirs: MutableList<String> by getConfig()
|
||||
val externalMediaDirs: MutableList<String> by getConfig()
|
||||
val rootDir: String by getConfig()
|
||||
val externalStorageDir: String by getConfig()
|
||||
val downloadCacheDir: String by getConfig()
|
||||
val databasesDir: String by getConfig()
|
||||
|
||||
val prefsDir: String by config
|
||||
val prefsDir: String by getConfig()
|
||||
|
||||
val packageDir: String by config
|
||||
val packageDir: String by getConfig()
|
||||
|
||||
companion object {
|
||||
fun register(config: Config) =
|
||||
FilesConfigModule(config.getConfig("android.files"))
|
||||
FilesConfigModule { config.getConfig("android.files") }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,19 +4,19 @@ import com.typesafe.config.Config
|
||||
import io.github.config4k.getValue
|
||||
import xyz.nulldev.ts.config.ConfigModule
|
||||
|
||||
class SystemConfigModule(val config: Config) : ConfigModule(config) {
|
||||
val isDebuggable: Boolean by config
|
||||
class SystemConfigModule(val getConfig: () -> Config) : ConfigModule(getConfig) {
|
||||
val isDebuggable: Boolean by getConfig()
|
||||
|
||||
val propertyPrefix = "properties."
|
||||
|
||||
fun getStringProperty(property: String) = config.getString("$propertyPrefix$property")!!
|
||||
fun getIntProperty(property: String) = config.getInt("$propertyPrefix$property")
|
||||
fun getLongProperty(property: String) = config.getLong("$propertyPrefix$property")
|
||||
fun getBooleanProperty(property: String) = config.getBoolean("$propertyPrefix$property")
|
||||
fun hasProperty(property: String) = config.hasPath("$propertyPrefix$property")
|
||||
fun getStringProperty(property: String) = getConfig().getString("$propertyPrefix$property")!!
|
||||
fun getIntProperty(property: String) = getConfig().getInt("$propertyPrefix$property")
|
||||
fun getLongProperty(property: String) = getConfig().getLong("$propertyPrefix$property")
|
||||
fun getBooleanProperty(property: String) = getConfig().getBoolean("$propertyPrefix$property")
|
||||
fun hasProperty(property: String) = getConfig().hasPath("$propertyPrefix$property")
|
||||
|
||||
companion object {
|
||||
fun register(config: Config) =
|
||||
SystemConfigModule(config.getConfig("android.system"))
|
||||
SystemConfigModule { config.getConfig("android.system") }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user