Improve the checking of an item's checksum

This commit is contained in:
croneter 2018-10-29 13:26:14 +01:00
parent 8c3764e8ad
commit ce002a0fa8
2 changed files with 6 additions and 6 deletions

View file

@ -81,9 +81,9 @@ class FullSync(backgroundthread.KillableThread, common.libsync_mixin):
if self.plexdb.is_recorded(plex_id, self.plex_type): if self.plexdb.is_recorded(plex_id, self.plex_type):
return return
else: else:
if self.plexdb.plex_id_by_checksum( if self.plexdb.checksum(plex_id, self.plex_type) == \
int('%s%s' % (plex_id, int('%s%s' % (plex_id,
xml_item.get('updatedAt')))): xml_item.get('updatedAt'))):
self.plexdb.update_last_sync(plex_id, self.last_sync) self.plexdb.update_last_sync(plex_id, self.last_sync)
return return
task = GetMetadataTask() task = GetMetadataTask()

View file

@ -94,12 +94,12 @@ class PlexDBBase(object):
self.cursor.execute(query, (last_sync, )) self.cursor.execute(query, (last_sync, ))
return (x[0] for x in self.cursor) 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 query = 'SELECT checksum FROM %s WHERE plex_id = ?' % plex_type
self.cursor.execute(query, (checksum, )) self.cursor.execute(query, (plex_id, ))
try: try:
return self.cursor.fetchone()[0] return self.cursor.fetchone()[0]
except TypeError: except TypeError: