utilities.py: Set checksum check to optional

Closes https://github.com/dortania/OpenCore-Legacy-Patcher/issues/915
This commit is contained in:
Mykola Grymalyuk
2022-02-05 09:14:23 -07:00
parent 3a9479a1d6
commit e2aa6b4b48
2 changed files with 13 additions and 7 deletions

View File

@@ -87,6 +87,7 @@ def download_install_assistant(download_path, ia_link):
return False
def install_macOS_installer(download_path):
print("- Extracting macOS installer from InstallAssistant.pkg\n This may take some time")
args = [
"osascript",
"-e",

View File

@@ -320,7 +320,7 @@ def verify_network_connection(url):
except (requests.exceptions.Timeout, requests.exceptions.TooManyRedirects, requests.exceptions.ConnectionError, requests.exceptions.HTTPError):
return False
def download_file(link, location, is_gui=None):
def download_file(link, location, is_gui=None, verify_checksum=False):
if verify_network_connection(link):
short_link = os.path.basename(link)
if Path(location).exists():
@@ -369,13 +369,18 @@ def download_file(link, location, is_gui=None):
if total_file_size > 1024:
total_downloaded_string = f" ({round(float(dl / total_file_size * 100), 2)}%)"
print(f"{round(count / 1024 / 1024, 2)}MB Downloaded{file_size_string}{total_downloaded_string}\nAverage Download Speed: {round(dl//(time.perf_counter() - start) / 100000 / 8, 2)} MB/s")
checksum = hashlib.sha256()
with location.open("rb") as file:
chunk = file.read(1024 * 1024 * 16)
while chunk:
checksum.update(chunk)
if verify_checksum is True:
# Verify checksum
# Note that this can be quite taxing on slower Macs
checksum = hashlib.sha256()
with location.open("rb") as file:
chunk = file.read(1024 * 1024 * 16)
return checksum
while chunk:
checksum.update(chunk)
chunk = file.read(1024 * 1024 * 16)
return checksum
return True
else:
cls()
header = "# Could not establish Network Connection with provided link! #"