1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-25 01:06:50 +00:00

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.
This commit is contained in:
Thomas Waldmann 2018-08-13 03:36:53 +02:00
parent 833c49f834
commit 66dd25ebc4
2 changed files with 2 additions and 2 deletions

View file

@ -625,7 +625,7 @@ def _process(self, *, path, parent_fd=None, name=None,
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,

View file

@ -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)