Fixed update mechanism when running Bazarr from %programdata%\Bazarr on Windows. #1768

This commit is contained in:
morpheus65535 2022-03-25 06:54:56 -04:00
parent 11ccbb278b
commit 55399380ad

View file

@ -194,16 +194,20 @@ def update_cleaner(zipfile, bazarr_dir, config_dir):
separator + '__pycache__' + separator + '$']
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)
dir_to_ignore.append('^backup' + separator)
dir_to_ignore.append('^cache' + separator)
dir_to_ignore.append('^config' + separator)
dir_to_ignore.append('^db' + separator)
dir_to_ignore.append('^log' + separator)
dir_to_ignore.append('^restore' + separator)
dir_to_ignore.append('^update' + separator)
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))
dir_to_ignore.append('^' + os.path.relpath(config_dir, bazarr_dir) + separator)
dir_to_ignore_regex_string = '(?:% s)' % '|'.join(dir_to_ignore)
logging.debug(f'BAZARR upgrade leftover cleaner will ignore directories matching this '
f'regex: {dir_to_ignore_regex.pattern}')
f'regex: {dir_to_ignore_regex_string}')
dir_to_ignore_regex = re.compile(dir_to_ignore_regex_string)
file_to_ignore = ['nssm.exe', '7za.exe', 'unins000.exe', 'unins000.dat']
logging.debug('BAZARR upgrade leftover cleaner will ignore those files: {}'.format(', '.join(file_to_ignore)))