Merge pull request #669 from croneter/pr_fix_delete
Fix PKC not deleting all the items it should
This commit is contained in:
commit
10e6caf3cd
2 changed files with 16 additions and 10 deletions
|
@ -372,12 +372,17 @@ class FullSync(common.fullsync_mixin):
|
||||||
])
|
])
|
||||||
for plex_type, context in kinds:
|
for plex_type, context in kinds:
|
||||||
# Delete movies that are not on Plex anymore
|
# Delete movies that are not on Plex anymore
|
||||||
with context(self.current_sync) as ctx:
|
while True:
|
||||||
for plex_id in ctx.plexdb.plex_id_by_last_sync(plex_type,
|
with context(self.current_sync) as ctx:
|
||||||
self.current_sync):
|
plex_ids = list(ctx.plexdb.plex_id_by_last_sync(plex_type,
|
||||||
if self.isCanceled():
|
self.current_sync,
|
||||||
return False
|
BATCH_SIZE))
|
||||||
ctx.remove(plex_id, plex_type)
|
for plex_id in plex_ids:
|
||||||
|
if self.isCanceled():
|
||||||
|
return False
|
||||||
|
ctx.remove(plex_id, plex_type)
|
||||||
|
if len(plex_ids) < BATCH_SIZE:
|
||||||
|
break
|
||||||
LOG.debug('Done deleting')
|
LOG.debug('Done deleting')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -100,13 +100,14 @@ class PlexDBBase(object):
|
||||||
method = getattr(self, 'entry_to_%s' % v.PLEX_TYPE_FROM_KODI_TYPE[kodi_type])
|
method = getattr(self, 'entry_to_%s' % v.PLEX_TYPE_FROM_KODI_TYPE[kodi_type])
|
||||||
return method(self.cursor.fetchone())
|
return method(self.cursor.fetchone())
|
||||||
|
|
||||||
def plex_id_by_last_sync(self, plex_type, last_sync):
|
def plex_id_by_last_sync(self, plex_type, last_sync, limit):
|
||||||
"""
|
"""
|
||||||
Returns an iterator for all items where the last_sync is NOT identical
|
Returns an iterator for all items where the last_sync is NOT identical
|
||||||
"""
|
"""
|
||||||
return (x[0] for x in
|
query = '''
|
||||||
self.cursor.execute('SELECT plex_id FROM %s WHERE last_sync <> ?' % plex_type,
|
SELECT plex_id FROM %s WHERE last_sync <> ? LIMIT %s
|
||||||
(last_sync, )))
|
''' % (plex_type, limit)
|
||||||
|
return (x[0] for x in self.cursor.execute(query, (last_sync, )))
|
||||||
|
|
||||||
def checksum(self, plex_id, plex_type):
|
def checksum(self, plex_id, plex_type):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue