From ea8f3bd7e7ae4d46bd6830bc1301bcfd8854b121 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Fri, 28 Aug 2015 23:22:26 +0200 Subject: [PATCH] restore_xattrs: minor cleanup / simplification if we use {} as default for item.get(), we do not need the "if" as iteration over an empty dict won't do anything. also fixes too deep indentation the original code had. --- borg/archive.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/borg/archive.py b/borg/archive.py index e214c7857..b2f14b668 100644 --- a/borg/archive.py +++ b/borg/archive.py @@ -323,14 +323,13 @@ class Archive: raise Exception('Unknown archive item type %r' % item[b'mode']) def restore_attrs(self, path, item, symlink=False, fd=None): - xattrs = item.get(b'xattrs') - if xattrs: - for k, v in xattrs.items(): - try: - xattr.setxattr(fd or path, k, v, follow_symlinks=False) - except OSError as e: - if e.errno != errno.ENOTSUP: - raise + xattrs = item.get(b'xattrs', {}) + for k, v in xattrs.items(): + try: + xattr.setxattr(fd or path, k, v, follow_symlinks=False) + except OSError as e: + if e.errno != errno.ENOTSUP: + raise uid = gid = None if not self.numeric_owner: uid = user2uid(item[b'user'])