mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-20 14:10:51 +10:00
utilities.py: Set checksum check to optional
Closes https://github.com/dortania/OpenCore-Legacy-Patcher/issues/915
This commit is contained in:
@@ -87,6 +87,7 @@ def download_install_assistant(download_path, ia_link):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def install_macOS_installer(download_path):
|
def install_macOS_installer(download_path):
|
||||||
|
print("- Extracting macOS installer from InstallAssistant.pkg\n This may take some time")
|
||||||
args = [
|
args = [
|
||||||
"osascript",
|
"osascript",
|
||||||
"-e",
|
"-e",
|
||||||
|
|||||||
+12
-7
@@ -320,7 +320,7 @@ def verify_network_connection(url):
|
|||||||
except (requests.exceptions.Timeout, requests.exceptions.TooManyRedirects, requests.exceptions.ConnectionError, requests.exceptions.HTTPError):
|
except (requests.exceptions.Timeout, requests.exceptions.TooManyRedirects, requests.exceptions.ConnectionError, requests.exceptions.HTTPError):
|
||||||
return False
|
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):
|
if verify_network_connection(link):
|
||||||
short_link = os.path.basename(link)
|
short_link = os.path.basename(link)
|
||||||
if Path(location).exists():
|
if Path(location).exists():
|
||||||
@@ -369,13 +369,18 @@ def download_file(link, location, is_gui=None):
|
|||||||
if total_file_size > 1024:
|
if total_file_size > 1024:
|
||||||
total_downloaded_string = f" ({round(float(dl / total_file_size * 100), 2)}%)"
|
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")
|
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:
|
if verify_checksum is True:
|
||||||
chunk = file.read(1024 * 1024 * 16)
|
# Verify checksum
|
||||||
while chunk:
|
# Note that this can be quite taxing on slower Macs
|
||||||
checksum.update(chunk)
|
checksum = hashlib.sha256()
|
||||||
|
with location.open("rb") as file:
|
||||||
chunk = file.read(1024 * 1024 * 16)
|
chunk = file.read(1024 * 1024 * 16)
|
||||||
return checksum
|
while chunk:
|
||||||
|
checksum.update(chunk)
|
||||||
|
chunk = file.read(1024 * 1024 * 16)
|
||||||
|
return checksum
|
||||||
|
return True
|
||||||
else:
|
else:
|
||||||
cls()
|
cls()
|
||||||
header = "# Could not establish Network Connection with provided link! #"
|
header = "# Could not establish Network Connection with provided link! #"
|
||||||
|
|||||||
Reference in New Issue
Block a user