From 5d8801e72c37548bab0540b4ce4bff4ad1404619 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 29 Dec 2022 23:53:10 +0100 Subject: [PATCH] macOS: fix mtime timestamp extraction if ResourceFork xattr is present, fixes #7234 setting the timestamps after xattrs helps for correct mtime, but atime is still broken in this case. --- src/borg/archive.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/borg/archive.py b/src/borg/archive.py index c736df66a..3fb51b141 100644 --- a/src/borg/archive.py +++ b/src/borg/archive.py @@ -951,6 +951,15 @@ def restore_attrs(self, path, item, symlink=False, fd=None): except NotImplementedError: if not symlink: os.chmod(path, item.mode) + if not self.noacls: + acl_set(path, item, self.numeric_ids, fd=fd) + if not self.noxattrs and "xattrs" in item: + # chown removes Linux capabilities, so set the extended attributes at the end, after chown, since they include + # the Linux capabilities in the "security.capability" attribute. + warning = xattr.set_all(fd or path, item.xattrs, follow_symlinks=False) + if warning: + set_ec(EXIT_WARNING) + # set timestamps rather late mtime = item.mtime atime = item.atime if "atime" in item else mtime if "birthtime" in item: @@ -973,14 +982,6 @@ def restore_attrs(self, path, item, symlink=False, fd=None): except OSError: # some systems don't support calling utime on a symlink pass - if not self.noacls: - acl_set(path, item, self.numeric_ids, fd=fd) - if not self.noxattrs and "xattrs" in item: - # chown removes Linux capabilities, so set the extended attributes at the end, after chown, since they include - # the Linux capabilities in the "security.capability" attribute. - warning = xattr.set_all(fd or path, item.xattrs, follow_symlinks=False) - if warning: - set_ec(EXIT_WARNING) # bsdflags include the immutable flag and need to be set last: if not self.noflags and "bsdflags" in item: try: