From 275aa24f58d061362e9ff8b0f6d14c0983bce844 Mon Sep 17 00:00:00 2001 From: morpheus65535 Date: Sat, 7 Aug 2021 18:57:34 -0400 Subject: [PATCH] Fixed issue with upgrade leftover cleanup on Windows. --- bazarr/check_update.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/bazarr/check_update.py b/bazarr/check_update.py index 0c45f0208..49fee7eea 100644 --- a/bazarr/check_update.py +++ b/bazarr/check_update.py @@ -176,12 +176,17 @@ def apply_update(): def update_cleaner(zipfile, bazarr_dir, config_dir): with ZipFile(zipfile, 'r') as archive: file_in_zip = archive.namelist() + if os.path.sep == '\\': + for i, item in enumerate(file_in_zip): + file_in_zip[i] = item.replace('/', '\\') - dir_to_ignore = ['^.' + os.path.sep, - '^bin' + os.path.sep, - '^venv' + os.path.sep, - '^WinPython' + os.path.sep, - os.path.sep + '__pycache__' + os.path.sep + '$'] + separator = os.path.sep * 2 if os.path.sep == '\\' else os.path.sep + + dir_to_ignore = ['^.' + separator, + '^bin' + separator, + '^venv' + separator, + '^WinPython' + separator, + separator + '__pycache__' + separator + '$'] if os.path.abspath(bazarr_dir) in os.path.abspath(config_dir): dir_to_ignore.append('^' + os.path.relpath(config_dir, bazarr_dir) + os.path.sep) dir_to_ignore_regex = re.compile('(?:% s)' % '|'.join(dir_to_ignore))