logo

live-bootstrap

Mirror of <https://github.com/fosslinux/live-bootstrap>
commit: db27ef0049fa07fdc014cd2341bc8f875701fc74
parent e0297e50c5cffbd6b5b71c3fa74418589d4656ab
Author: Andrius Štikonas <andrius@stikonas.eu>
Date:   Sat,  3 Jul 2021 19:54:47 +0100

Fix tarball download function.

We were using Python's requests library and it was automatically
uncompressing some tarballs. Switch to using raw requests to avoid that.

Diffstat:

Msysa.py8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sysa.py b/sysa.py @@ -76,8 +76,12 @@ class SysA: # Actually download the file if not os.path.isfile(abs_file_name): print("Downloading: %s" % (file_name)) - request = requests.get(url, allow_redirects=True) - open(abs_file_name, 'wb').write(request.content) + response = requests.get(url, allow_redirects=True, stream=True) + if response.status_code == 200: + with open(abs_file_name, 'wb') as target_file: + target_file.write(response.raw.read()) + else: + raise Exception("Download failed.") # Check SHA256 hash self.check_file(abs_file_name)