Fix for traceback when "exclude_from" value is empty in configuration file.

This commit is contained in:
Dan Helfman 2017-08-27 10:01:49 -07:00
parent 13ba5c84de
commit 7c048d1989
3 changed files with 12 additions and 1 deletions

1
NEWS
View file

@ -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.

View file

@ -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(

View file

@ -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},