diff --git a/borgmatic/borg/compact.py b/borgmatic/borg/compact.py index 2a6a717e..640b5361 100644 --- a/borgmatic/borg/compact.py +++ b/borgmatic/borg/compact.py @@ -41,13 +41,8 @@ def compact_segments( + flags.make_repository_flags(repository_path, local_borg_version) ) - if dry_run: - if feature.available(feature.Feature.DRY_RUN_COMPACT, local_borg_version): - logging.info('Skipping compact (dry run)') - else: - logging.warning( - 'The --dry-run option is not supported for compact in the current version of Borg.' - ) + if dry_run and not feature.available(feature.Feature.DRY_RUN_COMPACT, local_borg_version): + logging.info('Skipping compact (dry run)') return execute_command( diff --git a/tests/unit/borg/test_compact.py b/tests/unit/borg/test_compact.py index c370280e..e24dcc92 100644 --- a/tests/unit/borg/test_compact.py +++ b/tests/unit/borg/test_compact.py @@ -71,9 +71,7 @@ def test_compact_segments_with_log_debug_calls_borg_with_debug_flag(): def test_compact_segments_with_dry_run_skips_borg_call(): # Test borg version supports dry run. logger_mock = flexmock(logging) - logger_mock.should_receive('info').with_args('Skipping compact (dry run)').once() - - flexmock(module).should_receive('execute_command').never() + flexmock(module).should_receive('execute_command').once() module.compact_segments( repository_path='repo', @@ -84,9 +82,7 @@ def test_compact_segments_with_dry_run_skips_borg_call(): ) # Test borg version that does not support dry run. - logger_mock.should_receive('warning').with_args( - 'The --dry-run option is not supported for compact in the current version of Borg.' - ).once() + logger_mock.should_receive('info').with_args('Skipping compact (dry run)').once() module.compact_segments( repository_path='repo',