From 76a5878cdab2c4675c1d99fce69f2af15faf6a6a Mon Sep 17 00:00:00 2001 From: lowercasenumbers Date: Sat, 30 Sep 2023 15:33:08 -0400 Subject: [PATCH] Update extract_tar() to fix exception on .tar.gz files --- roles/install-tools/files/githubdownload.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/roles/install-tools/files/githubdownload.py b/roles/install-tools/files/githubdownload.py index 4fac3382..03100fb8 100644 --- a/roles/install-tools/files/githubdownload.py +++ b/roles/install-tools/files/githubdownload.py @@ -79,14 +79,13 @@ def extract_tar(compressed_data, out_file): Returns: Nothing """ try: - gzip_header = compressed_data.getvalue()[:10] - if gzip_header.startswith(b"\x1f\x8b"): - with gzip.open(compressed_data, "rb") as gz: - with tarfile.open(fileobj=gz, mode="r:gz") as tar: - tar.extractall(path=out_file) - return - else: - raise Exception("Unable to identify compression type") + gzip_header = compressed_data.getvalue()[:10] + if gzip_header.startswith(b"\x1f\x8b"): + tar = tarfile.open(fileobj=compressed_data) + tar.extractall(path=out_file) + return + else: + raise Exception("Unable to identify compression type") except Exception as e: raise Exception(e)