diff options
author | Lee Garrett <lgarrett@rocketjump.eu> | 2023-07-18 13:23:44 +0200 |
---|---|---|
committer | Lee Garrett <lgarrett@rocketjump.eu> | 2023-07-18 13:23:44 +0200 |
commit | aff27d44d75c760b1288814b4948fc2c4a937d6e (patch) | |
tree | cf44068a623e41bae78b03c7ee52e2e35273c20f /lib/ansible/galaxy | |
parent | a00ca87e07387d5be8152f7e1d2a69701f9949d6 (diff) | |
download | debian-ansible-core-aff27d44d75c760b1288814b4948fc2c4a937d6e.zip |
New upstream version 2.14.8
Diffstat (limited to 'lib/ansible/galaxy')
-rw-r--r-- | lib/ansible/galaxy/collection/__init__.py | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/lib/ansible/galaxy/collection/__init__.py b/lib/ansible/galaxy/collection/__init__.py index 23482665..75aec751 100644 --- a/lib/ansible/galaxy/collection/__init__.py +++ b/lib/ansible/galaxy/collection/__init__.py @@ -1516,6 +1516,13 @@ def install_artifact(b_coll_targz_path, b_collection_path, b_temp_path, signatur """ try: with tarfile.open(b_coll_targz_path, mode='r') as collection_tar: + # Remove this once py3.11 is our controller minimum + # Workaround for https://bugs.python.org/issue47231 + # See _extract_tar_dir + collection_tar._ansible_normalized_cache = { + m.name.removesuffix(os.path.sep): m for m in collection_tar.getmembers() + } # deprecated: description='TarFile member index' core_version='2.18' python_version='3.11' + # Verify the signature on the MANIFEST.json before extracting anything else _extract_tar_file(collection_tar, MANIFEST_FILENAME, b_collection_path, b_temp_path) @@ -1595,22 +1602,12 @@ def install_src(collection, b_collection_path, b_collection_output_path, artifac def _extract_tar_dir(tar, dirname, b_dest): """ Extracts a directory from a collection tar. """ - member_names = [to_native(dirname, errors='surrogate_or_strict')] - - # Create list of members with and without trailing separator - if not member_names[-1].endswith(os.path.sep): - member_names.append(member_names[-1] + os.path.sep) + dirname = to_native(dirname, errors='surrogate_or_strict').removesuffix(os.path.sep) - # Try all of the member names and stop on the first one that are able to successfully get - for member in member_names: - try: - tar_member = tar.getmember(member) - except KeyError: - continue - break - else: - # If we still can't find the member, raise a nice error. - raise AnsibleError("Unable to extract '%s' from collection" % to_native(member, errors='surrogate_or_strict')) + try: + tar_member = tar._ansible_normalized_cache[dirname] + except KeyError: + raise AnsibleError("Unable to extract '%s' from collection" % dirname) b_dir_path = os.path.join(b_dest, to_bytes(dirname, errors='surrogate_or_strict')) |