ソースを参照

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

Dan Helfman 2 年 前
コミット
1784ca5910
4 ファイル変更11 行追加3 行削除
  1. 2 0
      NEWS
  2. 1 1
      borgmatic/borg/check.py
  3. 1 1
      borgmatic/commands/borgmatic.py
  4. 7 1
      tests/unit/borg/test_check.py

+ 2 - 0
NEWS

@@ -3,6 +3,8 @@
    or monitoring), so not even errors are shown.
  * #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.
+ * #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
    configured repositories.
 

+ 1 - 1
borgmatic/borg/check.py

@@ -226,7 +226,7 @@ def make_check_flags(checks, archive_filter_flags):
     else:
         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)):
         return common_flags

+ 1 - 1
borgmatic/commands/borgmatic.py

@@ -36,7 +36,7 @@ from borgmatic.borg import version as borg_version
 from borgmatic.commands.arguments import parse_arguments
 from borgmatic.config import checks, collect, convert, validate
 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.verbosity import verbosity_to_log_level
 

+ 7 - 1
tests/unit/borg/test_check.py

@@ -356,12 +356,18 @@ def test_make_check_flags_with_archives_check_returns_flag():
     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-*'))
 
     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():
     flexmock(module.feature).should_receive('available').and_return(True)
     flexmock(module.flags).should_receive('make_match_archives_flags').and_return(())