Fix for Borg's interactive prompt on the "check --repair" action automatically getting answered "NO" (#730).

This commit is contained in:
Dan Helfman 2023-07-22 15:25:55 -07:00
parent 4d7a2876a5
commit 8a2514915c
5 changed files with 29 additions and 17 deletions

2
NEWS
View file

@ -1,5 +1,7 @@
1.8.1.dev0 1.8.1.dev0
* #728: Fix for "prune" action error when using the "keep_exclude_tags" option in configuration. * #728: Fix for "prune" action error when using the "keep_exclude_tags" option in configuration.
* #730: Fix for Borg's interactive prompt on the "check --repair" action automatically getting
answered "NO" even when the "check_i_know_what_i_am_doing" option isn't set.
1.8.0 1.8.0
* #575: BREAKING: For the "borgmatic borg" action, instead of implicitly injecting * #575: BREAKING: For the "borgmatic borg" action, instead of implicitly injecting

View file

@ -142,7 +142,7 @@ def filter_checks_on_frequency(
if datetime.datetime.now() < check_time + frequency_delta: if datetime.datetime.now() < check_time + frequency_delta:
remaining = check_time + frequency_delta - datetime.datetime.now() remaining = check_time + frequency_delta - datetime.datetime.now()
logger.info( logger.info(
f'Skipping {check} check due to configured frequency; {remaining} until next check' f'Skipping {check} check due to configured frequency; {remaining} until next check (use --force to check anyway)'
) )
filtered_checks.remove(check) filtered_checks.remove(check)

View file

@ -38,14 +38,16 @@ def make_environment(config):
option_name, option_name,
environment_variable_name, environment_variable_name,
) in DEFAULT_BOOL_OPTION_TO_DOWNCASE_ENVIRONMENT_VARIABLE.items(): ) in DEFAULT_BOOL_OPTION_TO_DOWNCASE_ENVIRONMENT_VARIABLE.items():
value = config.get(option_name, False) value = config.get(option_name)
environment[environment_variable_name] = 'yes' if value else 'no' if value is not None:
environment[environment_variable_name] = 'yes' if value else 'no'
for ( for (
option_name, option_name,
environment_variable_name, environment_variable_name,
) in DEFAULT_BOOL_OPTION_TO_UPPERCASE_ENVIRONMENT_VARIABLE.items(): ) in DEFAULT_BOOL_OPTION_TO_UPPERCASE_ENVIRONMENT_VARIABLE.items():
value = config.get(option_name, False) value = config.get(option_name)
environment[environment_variable_name] = 'YES' if value else 'NO' if value is not None:
environment[environment_variable_name] = 'YES' if value else 'NO'
return environment return environment

View file

@ -365,19 +365,19 @@ properties:
type: boolean type: boolean
description: | description: |
Bypass Borg error about a repository that has been moved. Defaults Bypass Borg error about a repository that has been moved. Defaults
to false. to not bypassing.
example: true example: true
unknown_unencrypted_repo_access_is_ok: unknown_unencrypted_repo_access_is_ok:
type: boolean type: boolean
description: | description: |
Bypass Borg error about a previously unknown unencrypted repository. Bypass Borg error about a previously unknown unencrypted repository.
Defaults to false. Defaults to not bypassing.
example: true example: true
check_i_know_what_i_am_doing: check_i_know_what_i_am_doing:
type: boolean type: boolean
description: | description: |
Bypass Borg confirmation about check with repair option. Bypass Borg confirmation about check with repair option. Defaults to
Defaults to false. an interactive prompt from Borg.
example: true example: true
extra_borg_options: extra_borg_options:
type: object type: object

View file

@ -19,28 +19,36 @@ def test_make_environment_with_ssh_command_should_set_environment():
assert environment.get('BORG_RSH') == 'ssh -C' assert environment.get('BORG_RSH') == 'ssh -C'
def test_make_environment_without_configuration_should_only_set_default_environment(): def test_make_environment_without_configuration_should_not_set_environment():
environment = module.make_environment({}) environment = module.make_environment({})
assert environment == { assert environment == {}
'BORG_RELOCATED_REPO_ACCESS_IS_OK': 'no',
'BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK': 'no',
'BORG_CHECK_I_KNOW_WHAT_I_AM_DOING': 'NO',
}
def test_make_environment_with_relocated_repo_access_should_override_default(): def test_make_environment_with_relocated_repo_access_true_should_set_environment_yes():
environment = module.make_environment({'relocated_repo_access_is_ok': True}) environment = module.make_environment({'relocated_repo_access_is_ok': True})
assert environment.get('BORG_RELOCATED_REPO_ACCESS_IS_OK') == 'yes' assert environment.get('BORG_RELOCATED_REPO_ACCESS_IS_OK') == 'yes'
def test_make_environment_check_i_know_what_i_am_doing_should_override_default(): def test_make_environment_with_relocated_repo_access_false_should_set_environment_no():
environment = module.make_environment({'relocated_repo_access_is_ok': False})
assert environment.get('BORG_RELOCATED_REPO_ACCESS_IS_OK') == 'no'
def test_make_environment_check_i_know_what_i_am_doing_true_should_set_environment_YES():
environment = module.make_environment({'check_i_know_what_i_am_doing': True}) environment = module.make_environment({'check_i_know_what_i_am_doing': True})
assert environment.get('BORG_CHECK_I_KNOW_WHAT_I_AM_DOING') == 'YES' assert environment.get('BORG_CHECK_I_KNOW_WHAT_I_AM_DOING') == 'YES'
def test_make_environment_check_i_know_what_i_am_doing_false_should_set_environment_NO():
environment = module.make_environment({'check_i_know_what_i_am_doing': False})
assert environment.get('BORG_CHECK_I_KNOW_WHAT_I_AM_DOING') == 'NO'
def test_make_environment_with_integer_variable_value(): def test_make_environment_with_integer_variable_value():
environment = module.make_environment({'borg_files_cache_ttl': 40}) environment = module.make_environment({'borg_files_cache_ttl': 40})
assert environment.get('BORG_FILES_CACHE_TTL') == '40' assert environment.get('BORG_FILES_CACHE_TTL') == '40'