From eae3341b01463bf5234dd131d7bfe384adeb7617 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Mon, 13 Jul 2026 15:58:35 -0700 Subject: [PATCH] Fix the "--progress" flag on the "compact" action to actually update the progress of segment compaction (#1333). --- NEWS | 2 ++ borgmatic/borg/compact.py | 3 ++- tests/unit/borg/test_compact.py | 10 ++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index b04499af..1d9f667c 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,8 @@ with a default port. * #1324: For the MariaDB and MySQL hooks, add "events", "routines", and "tablespaces" options for disabling dumping of scheduled events, stored routines, and tablespaces, respectively. + * #1333: Fix the "--progress" flag on the "compact" action to actually update the progress of + segment compaction. * Fix a bug in which the "compact" action does not pass a compact threshold of zero to Borg. 2.1.6 diff --git a/borgmatic/borg/compact.py b/borgmatic/borg/compact.py index b0d036bc..35df8f70 100644 --- a/borgmatic/borg/compact.py +++ b/borgmatic/borg/compact.py @@ -3,7 +3,7 @@ import shlex import borgmatic.config.paths from borgmatic.borg import environment, feature, flags -from borgmatic.execute import execute_command +from borgmatic.execute import DO_NOT_CAPTURE, execute_command logger = logging.getLogger(__name__) @@ -56,6 +56,7 @@ def compact_segments( execute_command( full_command, output_log_level=logging.INFO, + output_file=DO_NOT_CAPTURE if config.get('progress') else None, environment=environment.make_environment(config), working_directory=borgmatic.config.paths.get_working_directory(config), borg_local_path=local_path, diff --git a/tests/unit/borg/test_compact.py b/tests/unit/borg/test_compact.py index a04808d0..3e775120 100644 --- a/tests/unit/borg/test_compact.py +++ b/tests/unit/borg/test_compact.py @@ -10,6 +10,7 @@ from ..test_verbosity import insert_logging_mock def insert_execute_command_mock( compact_command, output_log_level, + output_file=None, working_directory=None, borg_exit_codes=None, ): @@ -20,6 +21,7 @@ def insert_execute_command_mock( flexmock(module).should_receive('execute_command').with_args( compact_command, output_log_level=output_log_level, + output_file=output_file, environment=None, working_directory=working_directory, borg_local_path=compact_command[0], @@ -184,7 +186,9 @@ def test_compact_segments_with_remote_path_calls_borg_with_remote_path_flags(): def test_compact_segments_with_progress_calls_borg_with_progress_flag(): flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',)) - insert_execute_command_mock((*COMPACT_COMMAND, '--progress', 'repo'), logging.INFO) + insert_execute_command_mock( + (*COMPACT_COMMAND, '--progress', 'repo'), logging.INFO, module.DO_NOT_CAPTURE + ) insert_logging_mock(logging.WARNING) module.compact_segments( @@ -199,7 +203,9 @@ def test_compact_segments_with_progress_calls_borg_with_progress_flag(): def test_compact_segments_with_log_json_and_progress_calls_borg_with_both_flags(): flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',)) insert_execute_command_mock( - (*COMPACT_COMMAND, '--log-json', '--progress', 'repo'), logging.INFO + (*COMPACT_COMMAND, '--log-json', '--progress', 'repo'), + logging.INFO, + module.DO_NOT_CAPTURE, ) insert_logging_mock(logging.WARNING)