use logger to print exception

This commit is contained in:
Aria Moradi 2021-03-28 02:11:40 +04:30
parent e3f65d2192
commit 1eb4a9c216

View File

@ -12,6 +12,7 @@ import eu.kanade.tachiyomi.App
import ir.armor.tachidesk.Main import ir.armor.tachidesk.Main
import ir.armor.tachidesk.database.makeDataBaseTables import ir.armor.tachidesk.database.makeDataBaseTables
import ir.armor.tachidesk.server.util.systemTray import ir.armor.tachidesk.server.util.systemTray
import mu.KotlinLogging
import net.harawata.appdirs.AppDirsFactory import net.harawata.appdirs.AppDirsFactory
import org.kodein.di.DI import org.kodein.di.DI
import org.kodein.di.conf.global import org.kodein.di.conf.global
@ -21,6 +22,8 @@ import xyz.nulldev.ts.config.ConfigKodeinModule
import xyz.nulldev.ts.config.GlobalConfigManager import xyz.nulldev.ts.config.GlobalConfigManager
import java.io.File import java.io.File
private val logger = KotlinLogging.logger {}
object applicationDirs { object applicationDirs {
val dataRoot = AppDirsFactory.getInstance().getUserDataDir("Tachidesk", null, null)!! val dataRoot = AppDirsFactory.getInstance().getUserDataDir("Tachidesk", null, null)!!
val extensionsRoot = "$dataRoot/extensions" val extensionsRoot = "$dataRoot/extensions"
@ -59,16 +62,14 @@ fun applicationSetup() {
try { try {
val dataConfFile = File("${applicationDirs.dataRoot}/server.conf") val dataConfFile = File("${applicationDirs.dataRoot}/server.conf")
if (!dataConfFile.exists()) { if (!dataConfFile.exists()) {
val inpStream = Main::class.java.getResourceAsStream("/server-reference.conf") Main::class.java.getResourceAsStream("/server-reference.conf").use { input ->
val outStream = dataConfFile.outputStream() dataConfFile.outputStream().use { output ->
input.copyTo(output)
inpStream.copyTo(outStream) }
}
inpStream.close()
outStream.close()
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() logger.error("Exception while creating initial server.conf:\n", e)
} }
makeDataBaseTables() makeDataBaseTables()