diff --git a/NEWS b/NEWS index 2df29ece..2e5abe7e 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,6 @@ 1.1.7.dev0 + * Fix for traceback when "exclude_from" value is empty in configuration file. * When pruning, make highest verbosity level list archives kept and pruned. * Clarification of Python 3 pip usage in documentation. diff --git a/borgmatic/borg/create.py b/borgmatic/borg/create.py index 2696e751..5073cc57 100644 --- a/borgmatic/borg/create.py +++ b/borgmatic/borg/create.py @@ -36,7 +36,7 @@ def _make_exclude_flags(location_config, exclude_patterns_filename=None): Given a location config dict with various exclude options, and a filename containing any exclude patterns, return the corresponding Borg flags as a tuple. ''' - exclude_filenames = tuple(location_config.get('exclude_from', ())) + ( + exclude_filenames = tuple(location_config.get('exclude_from') or ()) + ( (exclude_patterns_filename,) if exclude_patterns_filename else () ) exclude_from_flags = tuple( diff --git a/borgmatic/tests/unit/borg/test_create.py b/borgmatic/tests/unit/borg/test_create.py index 6d2aa458..6f9b5a38 100644 --- a/borgmatic/tests/unit/borg/test_create.py +++ b/borgmatic/tests/unit/borg/test_create.py @@ -88,6 +88,16 @@ def test_make_exclude_flags_includes_both_filenames_when_patterns_given_and_excl assert exclude_flags == ('--exclude-from', 'excludes', '--exclude-from', '/tmp/excludes') +def test_make_exclude_flags_considers_none_exclude_from_filenames_as_empty(): + flexmock(module).should_receive('_write_exclude_file').and_return(None) + + exclude_flags = module._make_exclude_flags( + location_config={'exclude_from': None}, + ) + + assert exclude_flags == () + + def test_make_exclude_flags_includes_exclude_caches_when_true_in_config(): exclude_flags = module._make_exclude_flags( location_config={'exclude_caches': True},