Fix "check" action error when repository and archive checks are configured but the archive check gets skipped due to the configured frequency (#704).

This commit is contained in:
Dan Helfman 2023-05-30 23:19:33 -07:00
parent 8f4cce5fa5
commit 1784ca5910
4 changed files with 11 additions and 3 deletions

2
NEWS
View file

@ -3,6 +3,8 @@
or monitoring), so not even errors are shown. or monitoring), so not even errors are shown.
* #688: Tweak archive check probing logic to use the newest timestamp found when multiple exist. * #688: Tweak archive check probing logic to use the newest timestamp found when multiple exist.
* #659: Add Borg 2 date-based matching flags to various actions for archive selection. * #659: Add Borg 2 date-based matching flags to various actions for archive selection.
* #704: Fix "check" action error when repository and archive checks are configured but the archive
check gets skipped due to the configured frequency.
* #706: Fix "--archive latest" on "list" and "info" actions only working on the first of multiple * #706: Fix "--archive latest" on "list" and "info" actions only working on the first of multiple
configured repositories. configured repositories.

View file

@ -226,7 +226,7 @@ def make_check_flags(checks, archive_filter_flags):
else: else:
data_flags = () data_flags = ()
common_flags = archive_filter_flags + data_flags common_flags = (archive_filter_flags if 'archives' in checks else ()) + data_flags
if {'repository', 'archives'}.issubset(set(checks)): if {'repository', 'archives'}.issubset(set(checks)):
return common_flags return common_flags

View file

@ -36,7 +36,7 @@ from borgmatic.borg import version as borg_version
from borgmatic.commands.arguments import parse_arguments from borgmatic.commands.arguments import parse_arguments
from borgmatic.config import checks, collect, convert, validate from borgmatic.config import checks, collect, convert, validate
from borgmatic.hooks import command, dispatch, monitor from borgmatic.hooks import command, dispatch, monitor
from borgmatic.logger import add_custom_log_levels, configure_logging, should_do_markup, DISABLED from borgmatic.logger import DISABLED, add_custom_log_levels, configure_logging, should_do_markup
from borgmatic.signals import configure_signals from borgmatic.signals import configure_signals
from borgmatic.verbosity import verbosity_to_log_level from borgmatic.verbosity import verbosity_to_log_level

View file

@ -356,12 +356,18 @@ def test_make_check_flags_with_archives_check_returns_flag():
assert flags == ('--archives-only',) assert flags == ('--archives-only',)
def test_make_check_flags_with_archive_filtler_flags_includes_those_flags(): def test_make_check_flags_with_archives_check_and_archive_filter_flags_includes_those_flags():
flags = module.make_check_flags(('archives',), ('--match-archives', 'sh:foo-*')) flags = module.make_check_flags(('archives',), ('--match-archives', 'sh:foo-*'))
assert flags == ('--archives-only', '--match-archives', 'sh:foo-*') assert flags == ('--archives-only', '--match-archives', 'sh:foo-*')
def test_make_check_flags_without_archives_check_and_with_archive_filter_flags_includes_those_flags():
flags = module.make_check_flags(('repository',), ('--match-archives', 'sh:foo-*'))
assert flags == ('--repository-only',)
def test_make_check_flags_with_data_check_returns_flag_and_implies_archives(): def test_make_check_flags_with_data_check_returns_flag_and_implies_archives():
flexmock(module.feature).should_receive('available').and_return(True) flexmock(module.feature).should_receive('available').and_return(True)
flexmock(module.flags).should_receive('make_match_archives_flags').and_return(()) flexmock(module.flags).should_receive('make_match_archives_flags').and_return(())