diff --git a/CHANGES.md b/CHANGES.md index c7b2e7c2..960a1382 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -63,6 +63,7 @@ * Change add 'nocache' kwarg to helpers.getURL to facilitate non-cached requests * Change instantly use saved value from Search Settings/Episode Search/"Check propers every" instead of after a restart * Change include OSError system messages in file system failure logs during post process +* Fix find associated meta files to prevent orphan episode images ### 0.11.11 (2016-04-05 19:20:00 UTC) diff --git a/sickbeard/postProcessor.py b/sickbeard/postProcessor.py index 3eca751a..0c913584 100644 --- a/sickbeard/postProcessor.py +++ b/sickbeard/postProcessor.py @@ -170,32 +170,33 @@ class PostProcessor(object): file_path_list = [] - base_name = file_path.rpartition('.')[0] + tmp_base = base_name = file_path.rpartition('.')[0] if not base_name_only: - base_name += '.' + tmp_base += '.' # don't strip it all and use cwd by accident - if not base_name: + if not tmp_base: return [] # don't confuse glob with chars we didn't mean to use base_name = re.sub(r'[\[\]\*\?]', r'[\g<0>]', base_name) - for associated_file_path in ek.ek(glob.glob, base_name + '*'): - # only add associated to list - if associated_file_path == file_path: - continue - # only list it if the only non-shared part is the extension or if it is a subtitle - if subtitles_only and not associated_file_path[len(associated_file_path) - 3:] in common.subtitleExtensions: - continue + for meta_ext in ['', '-thumb', '.ext', '.ext.cover', '.metathumb']: + for associated_file_path in ek.ek(glob.glob, '%s%s.*' % (base_name, meta_ext)): + # only add associated to list + if associated_file_path == file_path: + continue + # only list it if the only non-shared part is the extension or if it is a subtitle + if subtitles_only and not associated_file_path[len(associated_file_path) - 3:] in common.subtitleExtensions: + continue - # Exclude .rar files from associated list - if re.search('(^.+\.(rar|r\d+)$)', associated_file_path): - continue + # Exclude .rar files from associated list + if re.search('(^.+\.(rar|r\d+)$)', associated_file_path): + continue - if ek.ek(os.path.isfile, associated_file_path): - file_path_list.append(associated_file_path) + if ek.ek(os.path.isfile, associated_file_path): + file_path_list.append(associated_file_path) return file_path_list