diff options
author | Tim Burke <tim.burke@gmail.com> | 2023-03-24 13:27:24 -0700 |
---|---|---|
committer | Tim Burke <tim.burke@gmail.com> | 2023-05-02 13:20:03 -0700 |
commit | 780754096267851545f2aa97afb250064a2292e3 (patch) | |
tree | 76ef0d9ce786a594f7965ecc2e2d6f1c8e9d33c6 /swift/cli/info.py | |
parent | f99a6e5762896c7789d168bc49d8cdcb47903264 (diff) | |
download | swift-780754096267851545f2aa97afb250064a2292e3.tar.gz |
Properly read py2 object metadata on py3
Replicated, unencrypted metadata is written down differently on py2
vs py3, and has been since we started supporting py3. Fortunately,
we can inspect the raw xattr bytes to determine whether the pickle
was written using py2 or py3, so we can properly read legacy py2 meta
under py3 rather than hitting a unicode error.
Closes-Bug: #2012531
Change-Id: I5876e3b88f0bb1224299b57541788f590f64ddd4
Diffstat (limited to 'swift/cli/info.py')
-rw-r--r-- | swift/cli/info.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/swift/cli/info.py b/swift/cli/info.py index 7826a17b8..d99fb3b19 100644 --- a/swift/cli/info.py +++ b/swift/cli/info.py @@ -30,6 +30,7 @@ from swift.container.backend import ContainerBroker, DATADIR as CBDATADIR from swift.obj.diskfile import get_data_dir, read_metadata, DATADIR_BASE, \ extract_policy from swift.common.storage_policy import POLICIES +from swift.common.swob import wsgi_to_str from swift.common.middleware.crypto.crypto_utils import load_crypto_meta from swift.common.utils import md5 @@ -537,6 +538,8 @@ def print_obj(datafile, check_etag=True, swift_dir='/etc/swift', except EOFError: print("Invalid metadata") raise InfoSystemExit() + metadata = {wsgi_to_str(k): v if k == 'name' else wsgi_to_str(v) + for k, v in metadata.items()} etag = metadata.pop('ETag', '') length = metadata.pop('Content-Length', '') |