Don't delete library history if server_id doesn't match

This commit is contained in:
JonnyWong16 2020-04-12 20:49:45 -07:00
parent e0cd6f7071
commit 523e6421be
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
3 changed files with 37 additions and 22 deletions

View file

@ -1042,9 +1042,16 @@ class Libraries(object):
elif str(section_id).isdigit():
server_id = server_id or plexpy.CONFIG.PMS_IDENTIFIER
database.delete_library_history(server_id=server_id, section_id=section_id)
if server_id == plexpy.CONFIG.PMS_IDENTIFIER:
delete_success = database.delete_library_history(section_id=section_id)
else:
logger.warn(u"Tautulli Libraries :: Library history not deleted for library section_id %s "
u"because library server_id %s does not match Plex server identifier %s."
% (section_id, server_id, plexpy.CONFIG.PMS_IDENTIFIER))
delete_success = True
if purge_only:
return True
return delete_success
else:
logger.info(u"Tautulli Libraries :: Deleting library with server_id %s and section_id %s from database."
% (server_id, section_id))
@ -1052,7 +1059,7 @@ class Libraries(object):
monitor_db.action('UPDATE library_sections '
'SET deleted_section = 1, keep_history = 0, do_notify = 0, do_notify_created = 0 '
'WHERE server_id = ? AND section_id = ?', [server_id, section_id])
return True
return delete_success
except Exception as e:
logger.warn(u"Tautulli Libraries :: Unable to execute database query for delete: %s." % e)