mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 08:34:40 +01:00
ui, db: fixed loading db type from saved configuration
If a db from disk was being used, and the user changed it to in-memory, we were still loading the file from disk.
This commit is contained in:
parent
03e97903d6
commit
f288078c0b
2 changed files with 5 additions and 2 deletions
|
@ -20,11 +20,13 @@ class Database:
|
|||
self.db_file = Database.DB_IN_MEMORY
|
||||
self.db_name = dbname
|
||||
|
||||
def initialize(self, dbfile):
|
||||
def initialize(self, dbtype=DB_TYPE_MEMORY, dbfile=DB_IN_MEMORY):
|
||||
if dbtype != Database.DB_TYPE_MEMORY:
|
||||
self.db_file = dbfile
|
||||
|
||||
if self.db != None:
|
||||
QSqlDatabase.removeDatabase(self.db_name)
|
||||
self.close()
|
||||
self.db_file = dbfile
|
||||
|
||||
self.db = QSqlDatabase.addDatabase("QSQLITE", self.db_name)
|
||||
self.db.setDatabaseName(self.db_file)
|
||||
|
|
|
@ -38,6 +38,7 @@ class UIService(ui_pb2_grpc.UIServicer, QtWidgets.QGraphicsObject):
|
|||
self._cfg = Config.init()
|
||||
self._db = Database.instance()
|
||||
self._db.initialize(
|
||||
dbtype=self._cfg.getInt(self._cfg.DEFAULT_DB_TYPE_KEY),
|
||||
dbfile=self._cfg.getSettings(self._cfg.DEFAULT_DB_FILE_KEY)
|
||||
)
|
||||
self._db_sqlite = self._db.get_db()
|
||||
|
|
Loading…
Add table
Reference in a new issue