From e85e514c8b6f9c3c855853bec62a76f2e6ca52ff Mon Sep 17 00:00:00 2001 From: croneter Date: Fri, 1 Jun 2018 20:36:24 +0200 Subject: [PATCH] Fix endless reboots if Plex music library missing --- resources/lib/music.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/resources/lib/music.py b/resources/lib/music.py index 3f9ff941..5acc29e3 100644 --- a/resources/lib/music.py +++ b/resources/lib/music.py @@ -31,6 +31,7 @@ def excludefromscan_music_folders(): return # Build paths paths = [] + reboot = False api = API(item=None) for library in xml: 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) xml.set_setting(['audio', 'excludefromscan', 'regexp'], value=path, append=True) - # We only need to reboot if we ADD new paths! - reboot = xml.write_xml + if paths: + # We only need to reboot if we ADD new paths! + reboot = xml.write_xml # Delete obsolete entries + # Make sure we're not saving an empty audio-excludefromscan + xml.write_xml = reboot for element in parent: for path in paths: if element.text == path: @@ -67,6 +71,7 @@ def excludefromscan_music_folders(): LOG.info('Deleting music library from advancedsettings: %s', element.text) parent.remove(element) + xml.write_xml = True except (ParseError, IOError): LOG.error('Could not adjust advancedsettings.xml') reboot = False