mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-23 01:06:17 +00:00
IniSettings will be initialized at startup.
This commit is contained in:
parent
7fa89ab1b1
commit
89cca39409
@ -93,6 +93,10 @@ class CommandLineController {
|
|||||||
throw RuntimeException("Account / User mismatch")
|
throw RuntimeException("Account / User mismatch")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load the ini file.
|
||||||
|
IniSettings.load()
|
||||||
|
|
||||||
logger.debug("CommandLineOptions.cmd_login: {}", CommandLineOptions.cmd_login)
|
logger.debug("CommandLineOptions.cmd_login: {}", CommandLineOptions.cmd_login)
|
||||||
if (CommandLineOptions.cmd_login) {
|
if (CommandLineOptions.cmd_login) {
|
||||||
cmd_login(account)
|
cmd_login(account)
|
||||||
|
@ -13,7 +13,10 @@ object IniSettings {
|
|||||||
copySampleIni(UserManager.getInstance().fileBase + "config.sample.ini")
|
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)
|
val file = File(filename)
|
||||||
logger.trace("Checking ini file {}", filename.anonymize())
|
logger.trace("Checking ini file {}", filename.anonymize())
|
||||||
if (!file.exists()) return
|
if (!file.exists()) return
|
||||||
@ -21,7 +24,7 @@ object IniSettings {
|
|||||||
file.forEachLine { parseLine(it) }
|
file.forEachLine { parseLine(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun parseLine(original_line: String) {
|
private fun parseLine(original_line: String) {
|
||||||
logger.trace("Parsing line: {}", original_line)
|
logger.trace("Parsing line: {}", original_line)
|
||||||
var line = original_line.trim().replaceAfter("#", "").removeSuffix("#")
|
var line = original_line.trim().replaceAfter("#", "").removeSuffix("#")
|
||||||
logger.trace("After cleaning: {}", line)
|
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")
|
val stream = Config::class.java.getResourceAsStream("/config.sample.ini")
|
||||||
File(filename).outputStream().use { stream.copyTo(it) }
|
File(filename).outputStream().use { stream.copyTo(it) }
|
||||||
stream.close()
|
stream.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user