From 66dd25ebc4cd318802e7311a54e766090fd391b8 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 13 Aug 2018 03:36:53 +0200 Subject: [PATCH] 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. --- src/borg/archiver.py | 2 +- src/borg/helpers/fs.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/borg/archiver.py b/src/borg/archiver.py index 5747ed612..137701264 100644 --- a/src/borg/archiver.py +++ b/src/borg/archiver.py @@ -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, diff --git a/src/borg/helpers/fs.py b/src/borg/helpers/fs.py index 6c9d9556f..24c525d25 100644 --- a/src/borg/helpers/fs.py +++ b/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)