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
* #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
* #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:
remaining = check_time + frequency_delta - datetime.datetime.now()
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)

View File

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

View File

@ -365,19 +365,19 @@ properties:
type: boolean
description: |
Bypass Borg error about a repository that has been moved. Defaults
to false.
to not bypassing.
example: true
unknown_unencrypted_repo_access_is_ok:
type: boolean
description: |
Bypass Borg error about a previously unknown unencrypted repository.
Defaults to false.
Defaults to not bypassing.
example: true
check_i_know_what_i_am_doing:
type: boolean
description: |
Bypass Borg confirmation about check with repair option.
Defaults to false.
Bypass Borg confirmation about check with repair option. Defaults to
an interactive prompt from Borg.
example: true
extra_borg_options:
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'
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({})
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',
}
assert environment == {}
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})
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})
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():
environment = module.make_environment({'borg_files_cache_ttl': 40})
assert environment.get('BORG_FILES_CACHE_TTL') == '40'