Browse Source

extended stat: more fine grained exception handling

see #6988: it was unclear where exactly the error came from (flags, xattrs or ACLs getting?).
Thomas Waldmann 2 years ago
parent
commit
b5d43506d3
1 changed files with 12 additions and 8 deletions
  1. 12 8
      src/borg/archive.py

+ 12 - 8
src/borg/archive.py

@@ -1157,15 +1157,19 @@ class MetadataCollector:
 
 
     def stat_ext_attrs(self, st, path, fd=None):
     def stat_ext_attrs(self, st, path, fd=None):
         attrs = {}
         attrs = {}
-        with backup_io('extended stat'):
-            flags = 0 if self.noflags else get_flags(path, st, fd=fd)
-            xattrs = {} if self.noxattrs else xattr.get_all(fd or path, follow_symlinks=False)
-            if not self.noacls:
+        if not self.noflags:
+            with backup_io('extended stat (flags)'):
+                flags = get_flags(path, st, fd=fd)
+            if flags:
+                attrs['bsdflags'] = flags
+        if not self.noxattrs:
+            with backup_io('extended stat (xattrs)'):
+                xattrs = xattr.get_all(fd or path, follow_symlinks=False)
+            if xattrs:
+                attrs['xattrs'] = StableDict(xattrs)
+        if not self.noacls:
+            with backup_io('extended stat (ACLs)'):
                 acl_get(path, attrs, st, self.numeric_ids, fd=fd)
                 acl_get(path, attrs, st, self.numeric_ids, fd=fd)
-        if xattrs:
-            attrs['xattrs'] = StableDict(xattrs)
-        if flags:
-            attrs['bsdflags'] = flags
         return attrs
         return attrs
 
 
     def stat_attrs(self, st, path, fd=None):
     def stat_attrs(self, st, path, fd=None):