Background sync: wait till PMS says its finished
This commit is contained in:
parent
f82aa0511d
commit
b3b53c4cac
1 changed files with 11 additions and 12 deletions
|
@ -1477,13 +1477,12 @@ class LibrarySync(Thread):
|
||||||
now = getUnixTimestamp()
|
now = getUnixTimestamp()
|
||||||
deleteListe = []
|
deleteListe = []
|
||||||
for i, item in enumerate(self.itemsToProcess):
|
for i, item in enumerate(self.itemsToProcess):
|
||||||
if (now - item['timestamp'] < self.saftyMargin and
|
if item['state'] == 9:
|
||||||
item['state'] != 9):
|
successful = self.process_deleteditems(item)
|
||||||
|
elif now - item['timestamp'] < self.saftyMargin:
|
||||||
# We haven't waited long enough for the PMS to finish
|
# We haven't waited long enough for the PMS to finish
|
||||||
# processing the item. Do it later (excepting deletions)
|
# processing the item. Do it later (excepting deletions)
|
||||||
continue
|
continue
|
||||||
if item['state'] == 9:
|
|
||||||
successful = self.process_deleteditems(item)
|
|
||||||
else:
|
else:
|
||||||
successful, item = self.process_newitems(item)
|
successful, item = self.process_newitems(item)
|
||||||
if successful and settings('FanartTV') == 'true':
|
if successful and settings('FanartTV') == 'true':
|
||||||
|
@ -1502,7 +1501,7 @@ class LibrarySync(Thread):
|
||||||
# Safety net if we can't process an item
|
# Safety net if we can't process an item
|
||||||
item['attempt'] += 1
|
item['attempt'] += 1
|
||||||
if item['attempt'] > 3:
|
if item['attempt'] > 3:
|
||||||
log.warn('Repeatedly could not process item %s, abort'
|
log.error('Repeatedly could not process item %s, abort'
|
||||||
% item)
|
% item)
|
||||||
deleteListe.append(i)
|
deleteListe.append(i)
|
||||||
|
|
||||||
|
@ -1583,22 +1582,22 @@ class LibrarySync(Thread):
|
||||||
continue
|
continue
|
||||||
typus = int(item.get('type', 0))
|
typus = int(item.get('type', 0))
|
||||||
state = int(item.get('state', 0))
|
state = int(item.get('state', 0))
|
||||||
if state == 9 or typus in (1, 4, 10):
|
if state == 9 or (typus in (1, 4, 10) and state == 5):
|
||||||
# Only process deleted items OR movies, episodes, tracks/songs
|
# Only process deleted items OR movies, episodes, tracks/songs
|
||||||
itemId = str(item.get('itemID', '0'))
|
plex_id = str(item.get('itemID', '0'))
|
||||||
if itemId == '0':
|
if plex_id == '0':
|
||||||
log.warn('Received malformed PMS message: %s' % item)
|
log.error('Received malformed PMS message: %s' % item)
|
||||||
continue
|
continue
|
||||||
# Have we already added this element?
|
# Have we already added this element?
|
||||||
for existingItem in self.itemsToProcess:
|
for existingItem in self.itemsToProcess:
|
||||||
if existingItem['ratingKey'] == itemId:
|
if existingItem['ratingKey'] == plex_id:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
# Haven't added this element to the queue yet
|
# Haven't added this element to the queue yet
|
||||||
self.itemsToProcess.append({
|
self.itemsToProcess.append({
|
||||||
'state': state,
|
'state': state,
|
||||||
'type': typus,
|
'type': typus,
|
||||||
'ratingKey': itemId,
|
'ratingKey': plex_id,
|
||||||
'timestamp': getUnixTimestamp(),
|
'timestamp': getUnixTimestamp(),
|
||||||
'attempt': 0
|
'attempt': 0
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue