From d74b340024cad798c3a55c40f442162d76b928a3 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Sat, 6 Jun 2026 15:31:29 -0700 Subject: [PATCH] Fix a bug in which the "compact" action does not pass a compact threshold of zero to Borg. --- NEWS | 3 +++ borgmatic/borg/compact.py | 2 +- pyproject.toml | 2 +- tests/unit/borg/test_compact.py | 16 ++++++++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 2815f5fb..440c8355 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +2.1.7.dev0 + * Fix a bug in which the "compact" action does not pass a compact threshold of zero to Borg. + 2.1.6 * #1256: Fix a race condition in which borgmatic sometimes swallows Borg error output without logging it. diff --git a/borgmatic/borg/compact.py b/borgmatic/borg/compact.py index e9ffa99f..d3be5747 100644 --- a/borgmatic/borg/compact.py +++ b/borgmatic/borg/compact.py @@ -35,7 +35,7 @@ def compact_segments( + (('--lock-wait', str(lock_wait)) if lock_wait else ()) + (('--progress',) if config.get('progress') else ()) + (('--cleanup-commits',) if cleanup_commits else ()) - + (('--threshold', str(threshold)) if threshold else ()) + + (('--threshold', str(threshold)) if threshold is not None else ()) + (('--info',) if logger.getEffectiveLevel() == logging.INFO else ()) + (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ()) + ( diff --git a/pyproject.toml b/pyproject.toml index 503bdf80..18135582 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "borgmatic" -version = "2.1.6" +version = "2.1.7.dev0" authors = [ { name="Dan Helfman", email="witten@torsion.org" }, ] diff --git a/tests/unit/borg/test_compact.py b/tests/unit/borg/test_compact.py index 5c9b6bfe..1b61960e 100644 --- a/tests/unit/borg/test_compact.py +++ b/tests/unit/borg/test_compact.py @@ -229,6 +229,22 @@ def test_compact_segments_with_threshold_calls_borg_with_threshold_flag(): ) +def test_compact_segments_with_zero_threshold_calls_borg_with_threshold_flag(): + flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',)) + insert_execute_command_mock( + (*COMPACT_COMMAND, '--log-json', '--threshold', '0', 'repo'), logging.INFO + ) + insert_logging_mock(logging.WARNING) + + module.compact_segments( + dry_run=False, + repository_path='repo', + config={'compact_threshold': 0}, + local_borg_version='1.2.3', + global_arguments=flexmock(), + ) + + def test_compact_segments_with_umask_calls_borg_with_umask_flags(): config = {'umask': '077'} flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))