From 88b4a00d1bb9a142ae46d71d494cf272cdbbac7b Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 21 Mar 2019 03:20:12 +0100 Subject: [PATCH] freebsd xattr namespace: str vs. bytes fixup --- src/borg/xattr.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/borg/xattr.py b/src/borg/xattr.py index abe8e587f..8cdd18968 100644 --- a/src/borg/xattr.py +++ b/src/borg/xattr.py @@ -323,7 +323,7 @@ elif sys.platform.startswith('freebsd'): # pragma: freebsd only libc.extattr_set_file.argtypes = (c_char_p, c_int, c_char_p, c_char_p, c_size_t) libc.extattr_set_file.restype = c_int ns = EXTATTR_NAMESPACE_USER = 0x0001 - prefix = 'user.' + prefix, prefix_b = 'user.', b'user.' def listxattr(path, *, follow_symlinks=True): def func(path, buf, size): @@ -350,8 +350,9 @@ elif sys.platform.startswith('freebsd'): # pragma: freebsd only # strip namespace if there, but ignore if not there. # older borg / attic versions did not prefix the namespace to the names. - if name.startswith(prefix): - name = name[len(prefix):] + _prefix = prefix if isinstance(name, str) else prefix_b + if name.startswith(_prefix): + name = name[len(_prefix):] n, buf = _getxattr_inner(func, path, name) return buf[:n] or None @@ -367,8 +368,9 @@ elif sys.platform.startswith('freebsd'): # pragma: freebsd only # strip namespace if there, but ignore if not there. # older borg / attic versions did not prefix the namespace to the names. - if name.startswith(prefix): - name = name[len(prefix):] + _prefix = prefix if isinstance(name, str) else prefix_b + if name.startswith(_prefix): + name = name[len(_prefix):] _setxattr_inner(func, path, name, value) else: # pragma: unknown platform only