From ce002a0fa851543193148ec0b401b22460d3c2a9 Mon Sep 17 00:00:00 2001 From: croneter Date: Mon, 29 Oct 2018 13:26:14 +0100 Subject: [PATCH] Improve the checking of an item's checksum --- resources/lib/library_sync/full_sync.py | 4 ++-- resources/lib/plex_db/common.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/lib/library_sync/full_sync.py b/resources/lib/library_sync/full_sync.py index 1a461bae..cd9bf4de 100644 --- a/resources/lib/library_sync/full_sync.py +++ b/resources/lib/library_sync/full_sync.py @@ -81,9 +81,9 @@ class FullSync(backgroundthread.KillableThread, common.libsync_mixin): if self.plexdb.is_recorded(plex_id, self.plex_type): return else: - if self.plexdb.plex_id_by_checksum( + if self.plexdb.checksum(plex_id, self.plex_type) == \ int('%s%s' % (plex_id, - xml_item.get('updatedAt')))): + xml_item.get('updatedAt'))): self.plexdb.update_last_sync(plex_id, self.last_sync) return task = GetMetadataTask() diff --git a/resources/lib/plex_db/common.py b/resources/lib/plex_db/common.py index 263c25d9..9700cd29 100644 --- a/resources/lib/plex_db/common.py +++ b/resources/lib/plex_db/common.py @@ -94,12 +94,12 @@ class PlexDBBase(object): self.cursor.execute(query, (last_sync, )) return (x[0] for x in self.cursor) - def plex_id_by_checksum(self, checksum, plex_type): + def checksum(self, plex_id, plex_type): """ - Returns the plex_id for the (unique) checksum or None + Returns the checksum for plex_id """ - query = 'SELECT plex_id FROM %s WHERE checksum = ?' % plex_type - self.cursor.execute(query, (checksum, )) + query = 'SELECT checksum FROM %s WHERE plex_id = ?' % plex_type + self.cursor.execute(query, (plex_id, )) try: return self.cursor.fetchone()[0] except TypeError: