Revert "Wrap Kodi DB transactions explicitly"
This reverts commit be45d914d3
.
This commit is contained in:
parent
be45d914d3
commit
6de47490c3
3 changed files with 12 additions and 25 deletions
|
@ -56,11 +56,10 @@ class ItemBase(object):
|
||||||
"""
|
"""
|
||||||
self.plexconn = utils.kodi_sql('plex')
|
self.plexconn = utils.kodi_sql('plex')
|
||||||
self.plexcursor = self.plexconn.cursor()
|
self.plexcursor = self.plexconn.cursor()
|
||||||
|
self.kodiconn = utils.kodi_sql('video')
|
||||||
|
self.kodicursor = self.kodiconn.cursor()
|
||||||
self.artconn = utils.kodi_sql('texture')
|
self.artconn = utils.kodi_sql('texture')
|
||||||
self.artcursor = self.artconn.cursor()
|
self.artcursor = self.artconn.cursor()
|
||||||
self.kodiconn = utils.kodi_sql('video', writer=True)
|
|
||||||
self.kodicursor = self.kodiconn.cursor()
|
|
||||||
self.kodicursor.execute('BEGIN')
|
|
||||||
self.plexdb = PlexDB(self.plexcursor)
|
self.plexdb = PlexDB(self.plexcursor)
|
||||||
self.kodidb = KodiVideoDB(texture_db=True,
|
self.kodidb = KodiVideoDB(texture_db=True,
|
||||||
cursor=self.kodicursor,
|
cursor=self.kodicursor,
|
||||||
|
@ -72,20 +71,13 @@ class ItemBase(object):
|
||||||
Make sure DB changes are committed and connection to DB is closed.
|
Make sure DB changes are committed and connection to DB is closed.
|
||||||
"""
|
"""
|
||||||
self.plexconn.commit()
|
self.plexconn.commit()
|
||||||
|
self.kodiconn.commit()
|
||||||
|
self.artconn.commit()
|
||||||
self.plexconn.close()
|
self.plexconn.close()
|
||||||
self.artconn.commit()
|
|
||||||
self.artconn.close()
|
|
||||||
self.kodicursor.execute('END TRANSACTION')
|
|
||||||
self.kodiconn.close()
|
self.kodiconn.close()
|
||||||
|
self.artconn.close()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def commit(self):
|
|
||||||
self.plexconn.commit()
|
|
||||||
self.artconn.commit()
|
|
||||||
self.kodicursor.execute('END TRANSACTION')
|
|
||||||
self.kodicursor.execute('PRAGMA wal_checkpoint(FULL);')
|
|
||||||
self.kodicursor.execute('BEGIN TRANSACTION')
|
|
||||||
|
|
||||||
def set_fanart(self, artworks, kodi_id, kodi_type):
|
def set_fanart(self, artworks, kodi_id, kodi_type):
|
||||||
"""
|
"""
|
||||||
Writes artworks [dict containing only set artworks] to the Kodi art DB
|
Writes artworks [dict containing only set artworks] to the Kodi art DB
|
||||||
|
|
|
@ -123,12 +123,12 @@ class ProcessMetadata(backgroundthread.KillableThread, common.libsync_mixin):
|
||||||
self.processed += 1
|
self.processed += 1
|
||||||
self.update_progressbar()
|
self.update_progressbar()
|
||||||
self.current += 1
|
self.current += 1
|
||||||
if self.processed == 200:
|
if self.processed == 500:
|
||||||
self.processed = 0
|
self.processed = 0
|
||||||
context.commit()
|
context.kodiconn.commit()
|
||||||
|
context.artconn.commit()
|
||||||
|
context.plexconn.commit()
|
||||||
self.queue.task_done()
|
self.queue.task_done()
|
||||||
if section.plex_type == 'episode' and self.current == 1000:
|
|
||||||
break
|
|
||||||
profile.disable()
|
profile.disable()
|
||||||
string_io = StringIO()
|
string_io = StringIO()
|
||||||
stats = Stats(profile, stream=string_io).sort_stats('cumulative')
|
stats = Stats(profile, stream=string_io).sort_stats('cumulative')
|
||||||
|
|
|
@ -475,7 +475,7 @@ def unix_timestamp(seconds_into_the_future=None):
|
||||||
return int((future - EPOCH).total_seconds())
|
return int((future - EPOCH).total_seconds())
|
||||||
|
|
||||||
|
|
||||||
def kodi_sql(media_type=None, writer=False):
|
def kodi_sql(media_type=None):
|
||||||
"""
|
"""
|
||||||
Open a connection to the Kodi database.
|
Open a connection to the Kodi database.
|
||||||
media_type: 'video' (standard if not passed), 'plex', 'music', 'texture'
|
media_type: 'video' (standard if not passed), 'plex', 'music', 'texture'
|
||||||
|
@ -488,11 +488,6 @@ def kodi_sql(media_type=None, writer=False):
|
||||||
db_path = v.DB_TEXTURE_PATH
|
db_path = v.DB_TEXTURE_PATH
|
||||||
else:
|
else:
|
||||||
db_path = v.DB_VIDEO_PATH
|
db_path = v.DB_VIDEO_PATH
|
||||||
if writer:
|
|
||||||
conn = connect(db_path, timeout=5.0, isolation_level=None)
|
|
||||||
conn.execute('PRAGMA journal_mode=WAL')
|
|
||||||
# conn.execute('BEGIN TRANSACTION')
|
|
||||||
else:
|
|
||||||
conn = connect(db_path, timeout=5.0)
|
conn = connect(db_path, timeout=5.0)
|
||||||
conn.execute('PRAGMA journal_mode=WAL')
|
conn.execute('PRAGMA journal_mode=WAL')
|
||||||
return conn
|
return conn
|
||||||
|
|
Loading…
Reference in a new issue