mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-20 14:10:51 +10:00
Clean downloader_file funtion
This commit is contained in:
+10
-4
@@ -294,16 +294,22 @@ def download_file(link, location):
|
|||||||
if Path(location).exists():
|
if Path(location).exists():
|
||||||
Path(location).unlink()
|
Path(location).unlink()
|
||||||
response = requests.get(link, stream=True)
|
response = requests.get(link, stream=True)
|
||||||
|
short_link = os.path.basename(link)
|
||||||
|
# SU Catalog's link is quite long, strip to make it bearable
|
||||||
|
if "sucatalog.gz" in short_link:
|
||||||
|
short_link = "sucatalog.gz"
|
||||||
|
header = f"# Downloading: {short_link} #"
|
||||||
|
box_length = len(header)
|
||||||
with location.open("wb") as file:
|
with location.open("wb") as file:
|
||||||
count = 0
|
count = 0
|
||||||
for chunk in response.iter_content(1024 * 1024 * 4):
|
for chunk in response.iter_content(1024 * 1024 * 4):
|
||||||
file.write(chunk)
|
file.write(chunk)
|
||||||
count += len(chunk)
|
count += len(chunk)
|
||||||
cls()
|
cls()
|
||||||
print("####################")
|
print("#" * box_length)
|
||||||
print("# Downloading file #")
|
print(header)
|
||||||
print("####################")
|
print("#" * box_length)
|
||||||
print(link)
|
print("")
|
||||||
print(f"{count / 1024 / 1024}MB Downloaded")
|
print(f"{count / 1024 / 1024}MB Downloaded")
|
||||||
checksum = hashlib.sha256()
|
checksum = hashlib.sha256()
|
||||||
with location.open("rb") as file:
|
with location.open("rb") as file:
|
||||||
|
|||||||
Reference in New Issue
Block a user