mirror of
https://github.com/borgbase/vorta
synced 2025-01-03 05:36:19 +00:00
Cleanup database at exit, use write-ahead logging. By @samuel-w (#696)
This commit is contained in:
parent
abd41b9fea
commit
3112a111f7
4 changed files with 9 additions and 3 deletions
|
@ -48,7 +48,7 @@ def exception_handler(type, value, tb):
|
||||||
init_logger(background=want_background)
|
init_logger(background=want_background)
|
||||||
|
|
||||||
# Init database
|
# Init database
|
||||||
sqlite_db = peewee.SqliteDatabase(os.path.join(SETTINGS_DIR, 'settings.db'))
|
sqlite_db = peewee.SqliteDatabase(os.path.join(SETTINGS_DIR, 'settings.db'), pragmas={'journal_mode': 'wal', })
|
||||||
init_db(sqlite_db)
|
init_db(sqlite_db)
|
||||||
|
|
||||||
# Init app after database is available
|
# Init app after database is available
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
from vorta.borg.version import BorgVersionThread
|
from vorta.borg.version import BorgVersionThread
|
||||||
from vorta.config import TEMP_DIR
|
from vorta.config import TEMP_DIR
|
||||||
from vorta.i18n import init_translations, translate
|
from vorta.i18n import init_translations, translate
|
||||||
from vorta.models import BackupProfileModel, SettingsModel
|
from vorta.models import BackupProfileModel, SettingsModel, cleanup_db
|
||||||
from vorta.qt_single_application import QtSingleApplication
|
from vorta.qt_single_application import QtSingleApplication
|
||||||
from vorta.scheduler import VortaScheduler
|
from vorta.scheduler import VortaScheduler
|
||||||
from vorta.tray_menu import TrayMenu
|
from vorta.tray_menu import TrayMenu
|
||||||
|
@ -74,6 +74,7 @@ def __init__(self, args_raw, single_app=False):
|
||||||
self.backup_finished_event.connect(self.backup_finished_event_response)
|
self.backup_finished_event.connect(self.backup_finished_event_response)
|
||||||
self.backup_cancelled_event.connect(self.backup_cancelled_event_response)
|
self.backup_cancelled_event.connect(self.backup_cancelled_event_response)
|
||||||
self.message_received_event.connect(self.message_received_event_response)
|
self.message_received_event.connect(self.message_received_event_response)
|
||||||
|
self.aboutToQuit.connect(cleanup_db)
|
||||||
self.set_borg_details_action()
|
self.set_borg_details_action()
|
||||||
self.installEventFilter(self)
|
self.installEventFilter(self)
|
||||||
|
|
||||||
|
|
|
@ -252,6 +252,11 @@ def get_misc_settings():
|
||||||
return settings
|
return settings
|
||||||
|
|
||||||
|
|
||||||
|
def cleanup_db():
|
||||||
|
# Clean up database
|
||||||
|
db.execute_sql("VACUUM")
|
||||||
|
|
||||||
|
|
||||||
def init_db(con=None):
|
def init_db(con=None):
|
||||||
if con is not None:
|
if con is not None:
|
||||||
os.umask(0o0077)
|
os.umask(0o0077)
|
||||||
|
|
|
@ -66,7 +66,7 @@ def ensure_borg_thread_stopped():
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def qapp(tmpdir_factory, local_en):
|
def qapp(tmpdir_factory, local_en):
|
||||||
tmp_db = tmpdir_factory.mktemp('Vorta').join('settings.sqlite')
|
tmp_db = tmpdir_factory.mktemp('Vorta').join('settings.sqlite')
|
||||||
mock_db = peewee.SqliteDatabase(str(tmp_db))
|
mock_db = peewee.SqliteDatabase(str(tmp_db), pragmas={'journal_mode': 'wal', })
|
||||||
vorta.models.init_db(mock_db)
|
vorta.models.init_db(mock_db)
|
||||||
|
|
||||||
from vorta.application import VortaApp
|
from vorta.application import VortaApp
|
||||||
|
|
Loading…
Reference in a new issue