From afedf03ac9179e6c09afb99405df62f07531bb7d Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 11 Nov 2018 09:23:51 +0100 Subject: [PATCH] New method for DB commit --- resources/lib/itemtypes/common.py | 9 ++++++--- resources/lib/library_sync/process_metadata.py | 4 +--- resources/lib/utils.py | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/resources/lib/itemtypes/common.py b/resources/lib/itemtypes/common.py index d368c1fd..2861e8fa 100644 --- a/resources/lib/itemtypes/common.py +++ b/resources/lib/itemtypes/common.py @@ -70,14 +70,17 @@ class ItemBase(object): """ Make sure DB changes are committed and connection to DB is closed. """ - self.plexconn.commit() - self.kodiconn.commit() - self.artconn.commit() + self.commit() self.plexconn.close() self.kodiconn.close() self.artconn.close() return self + def commit(self): + self.plexconn.commit() + self.artconn.commit() + self.kodiconn.commit() + def set_fanart(self, artworks, kodi_id, kodi_type): """ Writes artworks [dict containing only set artworks] to the Kodi art DB diff --git a/resources/lib/library_sync/process_metadata.py b/resources/lib/library_sync/process_metadata.py index 54fd8632..b6e56a8a 100644 --- a/resources/lib/library_sync/process_metadata.py +++ b/resources/lib/library_sync/process_metadata.py @@ -125,9 +125,7 @@ class ProcessMetadata(backgroundthread.KillableThread, common.libsync_mixin): self.current += 1 if self.processed == 500: self.processed = 0 - context.kodiconn.commit() - context.artconn.commit() - context.plexconn.commit() + context.commit() self.queue.task_done() profile.disable() string_io = StringIO() diff --git a/resources/lib/utils.py b/resources/lib/utils.py index 56c1c102..b307d5d9 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -490,6 +490,7 @@ def kodi_sql(media_type=None): db_path = v.DB_VIDEO_PATH conn = connect(db_path, timeout=5.0) conn.execute('PRAGMA journal_mode=WAL') + conn.execute('PRAGMA wal_autocheckpoint=500;') return conn