瀏覽代碼

In the "spot" check, don't try to hash symlinked directories.

Dan Helfman 1 年之前
父節點
當前提交
08d6f83b2e
共有 3 個文件被更改,包括 15 次插入14 次删除
  1. 1 0
      NEWS
  2. 2 3
      borgmatic/actions/check.py
  3. 12 11
      tests/unit/actions/test_check.py

+ 1 - 0
NEWS

@@ -4,6 +4,7 @@
    the log level.
    the log level.
  * #874: Add the configured repository label as "repository_label" to the interpolated variables
  * #874: Add the configured repository label as "repository_label" to the interpolated variables
    passed to before/after command hooks.
    passed to before/after command hooks.
+ * In the "spot" check, don't try to hash symlinked directories.
 
 
 1.8.11
 1.8.11
  * #815: Add optional Healthchecks auto-provisioning via "create_slug" option.
  * #815: Add optional Healthchecks auto-provisioning via "create_slug" option.

+ 2 - 3
borgmatic/actions/check.py

@@ -300,8 +300,7 @@ def collect_spot_check_source_paths(
     '''
     '''
     Given a repository configuration dict, a configuration dict, the local Borg version, global
     Given a repository configuration dict, a configuration dict, the local Borg version, global
     arguments as an argparse.Namespace instance, the local Borg path, and the remote Borg path,
     arguments as an argparse.Namespace instance, the local Borg path, and the remote Borg path,
-    collect the source paths that Borg would use in an actual create (but only include files and
-    symlinks).
+    collect the source paths that Borg would use in an actual create (but only include files).
     '''
     '''
     stream_processes = any(
     stream_processes = any(
         borgmatic.hooks.dispatch.call_hooks(
         borgmatic.hooks.dispatch.call_hooks(
@@ -349,7 +348,7 @@ def collect_spot_check_source_paths(
         if path_line and path_line.startswith('- ') or path_line.startswith('+ ')
         if path_line and path_line.startswith('- ') or path_line.startswith('+ ')
     )
     )
 
 
-    return tuple(path for path in paths if os.path.isfile(path) or os.path.islink(path))
+    return tuple(path for path in paths if os.path.isfile(path))
 
 
 
 
 BORG_DIRECTORY_FILE_TYPE = 'd'
 BORG_DIRECTORY_FILE_TYPE = 'd'

+ 12 - 11
tests/unit/actions/test_check.py

@@ -520,7 +520,7 @@ def test_collect_spot_check_source_paths_without_working_directory_parses_borg_o
     ) == ('/etc/path', '/etc/other')
     ) == ('/etc/path', '/etc/other')
 
 
 
 
-def test_collect_spot_check_source_paths_includes_symlinks_but_skips_directories():
+def test_collect_spot_check_source_paths_skips_directories():
     flexmock(module.borgmatic.hooks.dispatch).should_receive('call_hooks').and_return(
     flexmock(module.borgmatic.hooks.dispatch).should_receive('call_hooks').and_return(
         {'hook1': False, 'hook2': True}
         {'hook1': False, 'hook2': True}
     )
     )
@@ -546,18 +546,19 @@ def test_collect_spot_check_source_paths_includes_symlinks_but_skips_directories
         'warning: stuff\n- /etc/path\n+ /etc/dir\n? /nope',
         'warning: stuff\n- /etc/path\n+ /etc/dir\n? /nope',
     )
     )
     flexmock(module.os.path).should_receive('isfile').with_args('/etc/path').and_return(False)
     flexmock(module.os.path).should_receive('isfile').with_args('/etc/path').and_return(False)
-    flexmock(module.os.path).should_receive('islink').with_args('/etc/path').and_return(True)
     flexmock(module.os.path).should_receive('isfile').with_args('/etc/dir').and_return(False)
     flexmock(module.os.path).should_receive('isfile').with_args('/etc/dir').and_return(False)
-    flexmock(module.os.path).should_receive('islink').with_args('/etc/dir').and_return(False)
 
 
-    assert module.collect_spot_check_source_paths(
-        repository={'path': 'repo'},
-        config={'working_directory': '/'},
-        local_borg_version=flexmock(),
-        global_arguments=flexmock(),
-        local_path=flexmock(),
-        remote_path=flexmock(),
-    ) == ('/etc/path',)
+    assert (
+        module.collect_spot_check_source_paths(
+            repository={'path': 'repo'},
+            config={'working_directory': '/'},
+            local_borg_version=flexmock(),
+            global_arguments=flexmock(),
+            local_path=flexmock(),
+            remote_path=flexmock(),
+        )
+        == ()
+    )
 
 
 
 
 def test_collect_spot_check_archive_paths_excludes_directories():
 def test_collect_spot_check_archive_paths_excludes_directories():