mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-22 08:46:15 +00:00
Database connection will now always be closed on VM shutdown.
This commit is contained in:
parent
4d45c7f1cc
commit
f434482cdf
@ -115,6 +115,10 @@ class CommandLineController(val options: CommandLineOptions) {
|
||||
// If we reach this point, we can assume that there is an account and a database can be loaded / created.
|
||||
database = Database(file_base, user_manager)
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(Thread() {
|
||||
database.close()
|
||||
})
|
||||
|
||||
// Load the settings and stuff.
|
||||
settings = Settings(file_base, database, options)
|
||||
|
||||
|
@ -662,6 +662,13 @@ class Database constructor(val file_base: String, val user_manager: UserManager)
|
||||
rs.close()
|
||||
return list
|
||||
}
|
||||
|
||||
fun close() {
|
||||
logger.debug("Closing database.")
|
||||
try { stmt.close() } catch (e: Throwable) { logger.debug("Exception during stmt.close()", e) }
|
||||
try { conn.close() } catch (e: Throwable) { logger.debug("Exception during conn.close()", e) }
|
||||
logger.debug("Database closed.")
|
||||
}
|
||||
|
||||
|
||||
abstract inner class AbstractChat {
|
||||
|
Loading…
Reference in New Issue
Block a user