Fix the "--progress" flag on the "compact" action to actually update the progress of segment compaction (#1333).

This commit is contained in:
Dan Helfman
2026-07-13 15:58:35 -07:00
parent 42743273d8
commit eae3341b01
3 changed files with 12 additions and 3 deletions
+2
View File
@@ -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
+2 -1
View File
@@ -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,
+8 -2
View File
@@ -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)