Browse Source

Fix normalization of deprecated sections to support empty sections without erroring (#771).

Dan Helfman 1 year ago
parent
commit
487d8ffd32
3 changed files with 8 additions and 1 deletions
  1. 2 0
      NEWS
  2. 1 1
      borgmatic/config/normalize.py
  3. 5 0
      tests/unit/config/test_normalize.py

+ 2 - 0
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

+ 1 - 1
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)

+ 5 - 0
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,
+        ),
         (
             {},
             {},