X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fbup%2Fmetadata.py;h=a04d01f1e25dc39bd78108bb78ee1bc51a5f3f5b;hb=d0af12b1a4023f8295840e64b6ee0d5848d576ba;hp=bb16892b6fa499fb46f41c906b79ee13e44adb88;hpb=bd26ba0f0b208e096a7c3068f8c62f846ad83824;p=bup.git diff --git a/lib/bup/metadata.py b/lib/bup/metadata.py index bb16892..a04d01f 100644 --- a/lib/bup/metadata.py +++ b/lib/bup/metadata.py @@ -465,9 +465,27 @@ class Metadata: self.linux_xattr = result def _apply_linux_xattr_rec(self, path, restore_numeric_ids=False): + existing_xattrs = set(xattr.list(path, nofollow=True)) if(self.linux_xattr): for k, v in self.linux_xattr: - xattr.set(path, k, v, nofollow=True) + if k not in existing_xattrs \ + or v != xattr.get(path, k, nofollow=True): + try: + xattr.set(path, k, v, nofollow=True) + except IOError, e: + if e.errno == errno.EPERM: + raise ApplyError('xattr.set: %s' % e) + else: + raise + existing_xattrs -= frozenset([k]) + for k in existing_xattrs: + try: + xattr.remove(path, k, nofollow=True) + except IOError, e: + if e.errno == errno.EPERM: + raise ApplyError('xattr.remove: %s' % e) + else: + raise def __init__(self): # optional members