diff --git a/sysa.py b/sysa.py index ec6ff27..ff2a2a5 100755 --- 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)