Fix endless reboots if Plex music library missing

This commit is contained in:
croneter 2018-06-01 20:36:24 +02:00
parent faf17f34d1
commit e85e514c8b

View file

@ -31,6 +31,7 @@ def excludefromscan_music_folders():
return return
# Build paths # Build paths
paths = [] paths = []
reboot = False
api = API(item=None) api = API(item=None)
for library in xml: for library in xml:
if library.attrib['type'] != v.PLEX_TYPE_ARTIST: if library.attrib['type'] != v.PLEX_TYPE_ARTIST:
@ -56,9 +57,12 @@ def excludefromscan_music_folders():
LOG.info('New Plex music library detected: %s', path) LOG.info('New Plex music library detected: %s', path)
xml.set_setting(['audio', 'excludefromscan', 'regexp'], xml.set_setting(['audio', 'excludefromscan', 'regexp'],
value=path, append=True) value=path, append=True)
if paths:
# We only need to reboot if we ADD new paths! # We only need to reboot if we ADD new paths!
reboot = xml.write_xml reboot = xml.write_xml
# Delete obsolete entries # Delete obsolete entries
# Make sure we're not saving an empty audio-excludefromscan
xml.write_xml = reboot
for element in parent: for element in parent:
for path in paths: for path in paths:
if element.text == path: if element.text == path:
@ -67,6 +71,7 @@ def excludefromscan_music_folders():
LOG.info('Deleting music library from advancedsettings: %s', LOG.info('Deleting music library from advancedsettings: %s',
element.text) element.text)
parent.remove(element) parent.remove(element)
xml.write_xml = True
except (ParseError, IOError): except (ParseError, IOError):
LOG.error('Could not adjust advancedsettings.xml') LOG.error('Could not adjust advancedsettings.xml')
reboot = False reboot = False