create: skip with warning if opening the parent dir of recursion root fails, fixes #6374

This commit is contained in:
Thomas Waldmann 2022-02-27 02:40:15 +01:00
parent eec359cf22
commit 8375d44328
1 changed files with 25 additions and 20 deletions

View File

@ -590,6 +590,7 @@ class Archiver:
path = os.path.normpath(path) path = os.path.normpath(path)
parent_dir = os.path.dirname(path) or '.' parent_dir = os.path.dirname(path) or '.'
name = os.path.basename(path) name = os.path.basename(path)
try:
# note: for path == '/': name == '' and parent_dir == '/'. # note: for path == '/': name == '' and parent_dir == '/'.
# the empty name will trigger a fall-back to path-based processing in os_stat and os_open. # the empty name will trigger a fall-back to path-based processing in os_stat and os_open.
with OsOpen(path=parent_dir, flags=flags_root, noatime=True, op='open_root') as parent_fd: with OsOpen(path=parent_dir, flags=flags_root, noatime=True, op='open_root') as parent_fd:
@ -610,6 +611,10 @@ class Archiver:
# if we get back here, we've finished recursing into <path>, # if we get back here, we've finished recursing into <path>,
# we do not ever want to get back in there (even if path is given twice as recursion root) # we do not ever want to get back in there (even if path is given twice as recursion root)
skip_inodes.add((st.st_ino, st.st_dev)) skip_inodes.add((st.st_ino, st.st_dev))
except (BackupOSError, BackupError) as e:
# this comes from OsOpen, self._rec_walk has own exception handler
self.print_warning('%s: %s', path, e)
continue
if not dry_run: if not dry_run:
if args.progress: if args.progress:
archive.stats.show_progress(final=True) archive.stats.show_progress(final=True)