浏览代码

Fix for incorrect /etc/borgmatic.d/ configuration path probing on macOS.

Dan 7 年之前
父节点
当前提交
3e26e70d0c
共有 4 个文件被更改,包括 22 次插入5 次删除
  1. 3 1
      NEWS
  2. 5 3
      borgmatic/config/collect.py
  3. 13 0
      borgmatic/tests/unit/config/test_collect.py
  4. 1 1
      setup.py

+ 3 - 1
NEWS

@@ -1,5 +1,7 @@
-1.1.11.dev0
+1.1.11
  * #25: Add "ssh_command" to configuration for specifying a custom SSH command or options.
+ * Fix for incorrect /etc/borgmatic.d/ configuration path probing on macOS. This problem manifested
+   as an error on startup: "[Errno 2] No such file or directory: '/etc/borgmatic.d'".
 
 1.1.10
  * Pass several Unix signals through to child processes like Borg. This means that Borg now properly

+ 5 - 3
borgmatic/config/collect.py

@@ -11,13 +11,15 @@ def collect_config_filenames(config_paths):
     files. This is non-recursive, so any directories within the given directories are ignored.
 
     Return paths even if they don't exist on disk, so the user can find out about missing
-    configuration paths. However, skip /etc/borgmatic.d if it's missing, so the user doesn't have to
-    create it unless they need it.
+    configuration paths. However, skip a default config path if it's missing, so the user doesn't
+    have to create a default config path unless they need it.
     '''
+    real_default_config_paths = set(map(os.path.realpath, DEFAULT_CONFIG_PATHS))
+
     for path in config_paths:
         exists = os.path.exists(path)
 
-        if os.path.realpath(path) in DEFAULT_CONFIG_PATHS and not exists:
+        if os.path.realpath(path) in real_default_config_paths and not exists:
             continue
 
         if not os.path.isdir(path) or not exists:

+ 13 - 0
borgmatic/tests/unit/config/test_collect.py

@@ -58,6 +58,19 @@ def test_collect_config_filenames_skips_etc_borgmatic_dot_d_if_it_does_not_exist
     assert config_filenames == ('config.yaml',)
 
 
+def test_collect_config_filenames_skips_non_canonical_etc_borgmatic_dot_d_if_it_does_not_exist():
+    config_paths = ('config.yaml', '/etc/../etc/borgmatic.d')
+    mock_path = flexmock(module.os.path)
+    mock_path.should_receive('exists').with_args('config.yaml').and_return(True)
+    mock_path.should_receive('exists').with_args('/etc/../etc/borgmatic.d').and_return(False)
+    mock_path.should_receive('isdir').with_args('config.yaml').and_return(False)
+    mock_path.should_receive('isdir').with_args('/etc/../etc/borgmatic.d').and_return(True)
+
+    config_filenames = tuple(module.collect_config_filenames(config_paths))
+
+    assert config_filenames == ('config.yaml',)
+
+
 def test_collect_config_filenames_includes_other_directory_if_it_does_not_exist():
     config_paths = ('config.yaml', '/my/directory')
     mock_path = flexmock(module.os.path)

+ 1 - 1
setup.py

@@ -1,7 +1,7 @@
 from setuptools import setup, find_packages
 
 
-VERSION = '1.1.11.dev0'
+VERSION = '1.1.11'
 
 
 setup(