Fixed upgrade leftover cleanup to prevent config reset when Bazarr is installed in the same directory as config and database. #1655

pull/1684/head v1.0.3-beta.12
morpheus65535 3 years ago
parent 9d30414f9d
commit a3a8ed93c7

@ -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 '

Loading…
Cancel
Save