From ead799d38bc3be4ea999925555e260ce773d7d73 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 11 Nov 2018 19:22:32 +0100 Subject: [PATCH] More fixes --- resources/lib/itemtypes/common.py | 3 +++ resources/lib/plex_db/common.py | 4 ++++ resources/lib/plex_functions.py | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/resources/lib/itemtypes/common.py b/resources/lib/itemtypes/common.py index 2861e8fa..f800a3cd 100644 --- a/resources/lib/itemtypes/common.py +++ b/resources/lib/itemtypes/common.py @@ -80,6 +80,9 @@ class ItemBase(object): self.plexconn.commit() self.artconn.commit() self.kodiconn.commit() + self.plexconn.execute('PRAGMA wal_checkpoint(TRUNCATE);') + self.artconn.execute('PRAGMA wal_checkpoint(TRUNCATE);') + self.kodiconn.execute('PRAGMA wal_checkpoint(TRUNCATE);') def set_fanart(self, artworks, kodi_id, kodi_type): """ diff --git a/resources/lib/plex_db/common.py b/resources/lib/plex_db/common.py index a56d0326..2b952ff5 100644 --- a/resources/lib/plex_db/common.py +++ b/resources/lib/plex_db/common.py @@ -249,6 +249,10 @@ def initialize(): kodi_type TEXT, kodi_hash TEXT) ''') + # DB indicees for faster lookups + plexdb.cursor.execute('CREATE UNIQUE INDEX IF NOT EXISTS ix_show_1 ON show (plex_id)') + plexdb.cursor.execute('CREATE UNIQUE INDEX IF NOT EXISTS ix_season_1 ON season (plex_id)') + plexdb.cursor.execute('CREATE UNIQUE INDEX IF NOT EXISTS ix_episode_1 ON episode (plex_id)') def wipe(): diff --git a/resources/lib/plex_functions.py b/resources/lib/plex_functions.py index fdb8301b..9c12cba7 100644 --- a/resources/lib/plex_functions.py +++ b/resources/lib/plex_functions.py @@ -618,7 +618,7 @@ class DownloadGen(object): child = self.xml[0] self.xml.remove(child) if (self.current % CONTAINERSIZE == 0 and - self.current < self.total - self.cache_factor * CONTAINERSIZE): + self.current < self.total - (self.cache_factor - 1) * CONTAINERSIZE): self.pending_counter.append(None) self._download_chunk( start=self.current + (self.cache_factor - 1) * CONTAINERSIZE)