From 50b3240c4fbcfcd54ee4141a2c1e498ebee2d97f Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Sun, 14 Jan 2018 14:09:20 -0800 Subject: [PATCH] 54: Fix for incorrect consistency check flags passed to Borg when all three checks in borgmatic config. --- NEWS | 2 ++ borgmatic/borg/check.py | 6 ++++-- borgmatic/tests/unit/borg/test_check.py | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index f182beb..9ba7599 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ 1.1.13.dev0 + * #54: Fix for incorrect consistency check flags passed to Borg when all three checks ("repository", + "archives", and "extract") are specified in borgmatic configuration. * Moved issue tracker from Taiga to integrated Gitea tracker at https://projects.torsion.org/witten/borgmatic/issues diff --git a/borgmatic/borg/check.py b/borgmatic/borg/check.py index e9afc33..04bac9c 100644 --- a/borgmatic/borg/check.py +++ b/borgmatic/borg/check.py @@ -46,10 +46,12 @@ def _make_check_flags(checks, check_last=None): ('--repository-only',) - Additionally, if a check_last value is given, a "--last" flag will be added. + However, if both "repository" and "archives" are in checks, then omit them from the returned + flags because Borg does both checks by default. Additionally, if a check_last value is given, + a "--last" flag will be added. ''' last_flag = ('--last', str(check_last)) if check_last else () - if checks == DEFAULT_CHECKS: + if set(DEFAULT_CHECKS).issubset(set(checks)): return last_flag return tuple( diff --git a/borgmatic/tests/unit/borg/test_check.py b/borgmatic/tests/unit/borg/test_check.py index 2b66f09..ed9339c 100644 --- a/borgmatic/tests/unit/borg/test_check.py +++ b/borgmatic/tests/unit/borg/test_check.py @@ -60,6 +60,12 @@ def test_make_check_flags_with_default_checks_returns_no_flags(): assert flags == () +def test_make_check_flags_with_all_checks_returns_no_flags(): + flags = module._make_check_flags(module.DEFAULT_CHECKS + ('extract',)) + + assert flags == () + + def test_make_check_flags_with_checks_and_last_returns_flags_including_last(): flags = module._make_check_flags(('repository',), check_last=3)