mirror of
				https://github.com/fabianonline/telegram_backup.git
				synced 2025-11-04 09:37:46 +00:00 
			
		
		
		
	Database connection will now always be closed on VM shutdown.
This commit is contained in:
		@@ -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.
 | 
								// 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)
 | 
								database = Database(file_base, user_manager)
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
 | 
								Runtime.getRuntime().addShutdownHook(Thread() {
 | 
				
			||||||
 | 
									database.close()
 | 
				
			||||||
 | 
								})
 | 
				
			||||||
 | 
								
 | 
				
			||||||
			// Load the settings and stuff.
 | 
								// Load the settings and stuff.
 | 
				
			||||||
			settings = Settings(file_base, database, options)
 | 
								settings = Settings(file_base, database, options)
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -663,6 +663,13 @@ class Database constructor(val file_base: String, val user_manager: UserManager)
 | 
				
			|||||||
		return list
 | 
							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 {
 | 
						abstract inner class AbstractChat {
 | 
				
			||||||
		abstract val query: String
 | 
							abstract val query: String
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user