diff --git a/src/main/kotlin/de/fabianonline/telegram_backup/CommandLineController.kt b/src/main/kotlin/de/fabianonline/telegram_backup/CommandLineController.kt index 4286ccd..11ab5b0 100644 --- a/src/main/kotlin/de/fabianonline/telegram_backup/CommandLineController.kt +++ b/src/main/kotlin/de/fabianonline/telegram_backup/CommandLineController.kt @@ -93,6 +93,10 @@ class CommandLineController { throw RuntimeException("Account / User mismatch") } } + + // Load the ini file. + IniSettings.load() + logger.debug("CommandLineOptions.cmd_login: {}", CommandLineOptions.cmd_login) if (CommandLineOptions.cmd_login) { cmd_login(account) diff --git a/src/main/kotlin/de/fabianonline/telegram_backup/IniSettings.kt b/src/main/kotlin/de/fabianonline/telegram_backup/IniSettings.kt index 8f811fb..ffa5bf2 100644 --- a/src/main/kotlin/de/fabianonline/telegram_backup/IniSettings.kt +++ b/src/main/kotlin/de/fabianonline/telegram_backup/IniSettings.kt @@ -13,7 +13,10 @@ object IniSettings { copySampleIni(UserManager.getInstance().fileBase + "config.sample.ini") } - fun loadIni(filename: String) { + // Dummy function that can be called to force this object to run its init-code. + fun load() { } + + private fun loadIni(filename: String) { val file = File(filename) logger.trace("Checking ini file {}", filename.anonymize()) if (!file.exists()) return @@ -21,7 +24,7 @@ object IniSettings { file.forEachLine { parseLine(it) } } - fun parseLine(original_line: String) { + private fun parseLine(original_line: String) { logger.trace("Parsing line: {}", original_line) var line = original_line.trim().replaceAfter("#", "").removeSuffix("#") logger.trace("After cleaning: {}", line) @@ -43,7 +46,7 @@ object IniSettings { } } - fun copySampleIni(filename: String) { + private fun copySampleIni(filename: String) { val stream = Config::class.java.getResourceAsStream("/config.sample.ini") File(filename).outputStream().use { stream.copyTo(it) } stream.close()