From 9b2ca15de6ba5ad17b0aac19156c1ef6571764a7 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Sat, 30 Nov 2019 15:31:36 -0800 Subject: [PATCH] Fix for garbled Borg file listing when using "borgmatic create --progress" with verbosity level 1 or 2 (#257). --- NEWS | 5 ++++- borgmatic/borg/create.py | 6 +++++- tests/unit/borg/test_create.py | 25 +++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 9233382..d019c5b 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ 1.4.16 - * Fix for missing Healthchecks monitoring payload or HTTP 500 due to incorrect unicode encoding. + * #257: Fix for garbled Borg file listing when using "borgmatic create --progress" with + verbosity level 1 or 2. + * #260: Fix for missing Healthchecks monitoring payload or HTTP 500 due to incorrect unicode + encoding. 1.4.15 * Fix for database dump removal incorrectly skipping some database dumps. diff --git a/borgmatic/borg/create.py b/borgmatic/borg/create.py index f3e8c2a..3190a8f 100644 --- a/borgmatic/borg/create.py +++ b/borgmatic/borg/create.py @@ -170,7 +170,11 @@ def create_archive( + (('--remote-path', remote_path) if remote_path else ()) + (('--umask', str(umask)) if umask else ()) + (('--lock-wait', str(lock_wait)) if lock_wait else ()) - + (('--list', '--filter', 'AME-') if logger.isEnabledFor(logging.INFO) and not json else ()) + + ( + ('--list', '--filter', 'AME-') + if logger.isEnabledFor(logging.INFO) and not json and not progress + else () + ) + (('--info',) if logger.getEffectiveLevel() == logging.INFO and not json else ()) + ( ('--stats',) diff --git a/tests/unit/borg/test_create.py b/tests/unit/borg/test_create.py index 156be57..d2cb12f 100644 --- a/tests/unit/borg/test_create.py +++ b/tests/unit/borg/test_create.py @@ -821,6 +821,31 @@ def test_create_archive_with_stats_calls_borg_with_stats_parameter(): ) +def test_create_archive_with_progress_and_log_info_calls_borg_with_progress_parameter_and_no_list(): + flexmock(module).should_receive('borgmatic_source_directories').and_return([]) + flexmock(module).should_receive('_expand_directories').and_return(('foo', 'bar')) + flexmock(module).should_receive('_expand_home_directories').and_return(()) + flexmock(module).should_receive('_write_pattern_file').and_return(None) + flexmock(module).should_receive('_make_pattern_flags').and_return(()) + flexmock(module).should_receive('_make_exclude_flags').and_return(()) + flexmock(module).should_receive('execute_command_without_capture').with_args( + ('borg', 'create', '--info', '--stats', '--progress') + ARCHIVE_WITH_PATHS + ) + insert_logging_mock(logging.INFO) + + module.create_archive( + dry_run=False, + repository='repo', + location_config={ + 'source_directories': ['foo', 'bar'], + 'repositories': ['repo'], + 'exclude_patterns': None, + }, + storage_config={}, + progress=True, + ) + + def test_create_archive_with_progress_calls_borg_with_progress_parameter(): flexmock(module).should_receive('borgmatic_source_directories').and_return([]) flexmock(module).should_receive('_expand_directories').and_return(('foo', 'bar'))