From a3a8ed93c7754a288957f6712ee1002f173bf4d4 Mon Sep 17 00:00:00 2001 From: morpheus65535 Date: Mon, 17 Jan 2022 00:01:05 -0500 Subject: [PATCH] Fixed upgrade leftover cleanup to prevent config reset when Bazarr is installed in the same directory as config and database. #1655 --- bazarr/check_update.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bazarr/check_update.py b/bazarr/check_update.py index 523d8b388..99ff880c6 100644 --- a/bazarr/check_update.py +++ b/bazarr/check_update.py @@ -192,7 +192,14 @@ def update_cleaner(zipfile, bazarr_dir, config_dir): '^venv' + separator, '^WinPython' + separator, separator + '__pycache__' + separator + '$'] - if os.path.abspath(bazarr_dir).lower() in os.path.abspath(config_dir).lower(): + if os.path.abspath(bazarr_dir).lower() == os.path.abspath(config_dir).lower(): + # for users who installed Bazarr inside the config directory (ie: `%programdata%\Bazarr` on windows) + with os.scandir(config_dir) as directories: + for directory in directories: + if directory.is_dir(): + dir_to_ignore.append('^' + directory.name + os.path.sep) + elif os.path.abspath(bazarr_dir).lower() in os.path.abspath(config_dir).lower(): + # when config directory is a child of Bazarr installation directory 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)) logging.debug(f'BAZARR upgrade leftover cleaner will ignore directories matching this '