Fix rare case where thousands of identical playlists could be generated

This commit is contained in:
croneter 2019-02-08 15:15:52 +01:00
parent f24266fb54
commit 873c9e74f5

View file

@ -17,7 +17,7 @@ LOG = getLogger('PLEX.playlists.kodi_pl')
############################################################################### ###############################################################################
REGEX_FILE_NUMBERING = re.compile(r'''_(\d+)\.\w+$''') REGEX_FILE_NUMBERING = re.compile(r'''_(\d\d)\.\w+$''')
def create(plex_id): def create(plex_id):
@ -53,6 +53,10 @@ def create(plex_id):
'%s_01.m3u' % name[:min(len(name), 248)]) '%s_01.m3u' % name[:min(len(name), 248)])
else: else:
number = int(occurance.group(1)) + 1 number = int(occurance.group(1)) + 1
if number > 3:
LOG.error('Detected spanning tree issue, abort sync for %s',
playlist)
raise PlaylistError('Spanning tree warning')
basename = re.sub(REGEX_FILE_NUMBERING, '', path) basename = re.sub(REGEX_FILE_NUMBERING, '', path)
path = '%s_%02d.m3u' % (basename, number) path = '%s_%02d.m3u' % (basename, number)
LOG.debug('Kodi playlist path: %s', path) LOG.debug('Kodi playlist path: %s', path)