From 487d8ffd329da17227e210dcd6accc19ab502a98 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Sat, 14 Oct 2023 13:04:18 -0700 Subject: [PATCH] Fix normalization of deprecated sections to support empty sections without erroring (#771). --- NEWS | 2 ++ borgmatic/config/normalize.py | 2 +- tests/unit/config/test_normalize.py | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index c612360..45f57cb 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ Apprise library. See the documentation for more information: https://torsion.org/borgmatic/docs/how-to/monitor-your-backups/#apprise-hook * #768: Fix a traceback when an invalid command-line flag or action is used. + * #771: Fix normalization of deprecated sections ("location:", "storage:", "hooks:", etc.) to + support empty sections without erroring. 1.8.3 * #665: BREAKING: Simplify logging logic as follows: Syslog verbosity is now disabled by diff --git a/borgmatic/config/normalize.py b/borgmatic/config/normalize.py index 5fb02d8..1198bb5 100644 --- a/borgmatic/config/normalize.py +++ b/borgmatic/config/normalize.py @@ -39,7 +39,7 @@ def normalize_sections(config_filename, config): for section_name in ('location', 'storage', 'retention', 'consistency', 'output', 'hooks'): section_config = config.get(section_name) - if section_config: + if section_config is not None: any_section_upgraded = True del config[section_name] config.update(section_config) diff --git a/tests/unit/config/test_normalize.py b/tests/unit/config/test_normalize.py index 6a9d640..ebe6874 100644 --- a/tests/unit/config/test_normalize.py +++ b/tests/unit/config/test_normalize.py @@ -77,6 +77,11 @@ from borgmatic.config import normalize as module {'bar': 'baz', 'prefix': 'foo'}, True, ), + ( + {'location': {}, 'consistency': {'prefix': 'foo'}}, + {'prefix': 'foo'}, + True, + ), ( {}, {},