瀏覽代碼

when scandir gets called with an FD, dirent.path is not usable

if scandir does not get a path, it can't prefix it in front of the
filename in the direntries it returns, so dirent.path == dirent.name.

thus, we just only use dirent.name and construct the full path.
Thomas Waldmann 6 年之前
父節點
當前提交
66dd25ebc4
共有 2 個文件被更改,包括 2 次插入2 次删除
  1. 1 1
      src/borg/archiver.py
  2. 1 1
      src/borg/helpers/fs.py

+ 1 - 1
src/borg/archiver.py

@@ -625,7 +625,7 @@ class Archiver:
                         with backup_io('scandir'):
                             entries = helpers.scandir_inorder(path=path, fd=child_fd)
                         for dirent in entries:
-                            normpath = os.path.normpath(dirent.path)
+                            normpath = os.path.normpath(os.path.join(path, dirent.name))
                             self._process(path=normpath, parent_fd=child_fd, name=dirent.name,
                                           fso=fso, cache=cache, matcher=matcher,
                                           exclude_caches=exclude_caches, exclude_if_present=exclude_if_present,

+ 1 - 1
src/borg/helpers/fs.py

@@ -149,7 +149,7 @@ def scandir_keyfunc(dirent):
 
 
 def scandir_inorder(*, path, fd=None):
-    # py37+ supports giving a fd instead of a path
+    # py37+ supports giving an fd instead of a path (no full entry.path in DirEntry in that case!)
     arg = fd if fd is not None and py_37_plus else path
     return sorted(os.scandir(arg), key=scandir_keyfunc)