Redundancy for some downloads.

This commit is contained in:
Storm Dragon
2026-04-28 19:46:15 -04:00
parent b6d77279f7
commit f50b872f6a
+19 -3
View File
@@ -45,9 +45,16 @@ def internet_available():
return False
def apple_support_url():
def apple_support_urls():
gateway = os.environ.get("ipfsGateway", "https://ipfs.stormux.org")
return f"{gateway}/ipfs/{APPLE2E_CID}?filename={APPLE2E_ZIP_NAME}"
gateways = (gateway, "https://ipfs.io", "https://dweb.link")
urls = []
for currentGateway in gateways:
currentGateway = currentGateway.rstrip("/")
currentUrl = f"{currentGateway}/ipfs/{APPLE2E_CID}?filename={APPLE2E_ZIP_NAME}"
if currentUrl not in urls:
urls.append(currentUrl)
return urls
def sha256_file(filePath):
@@ -147,7 +154,16 @@ def ensure_apple_support_files(
zipPath = cacheDir / APPLE2E_ZIP_NAME
speak("Apple 2e support files are not installed. Downloading them now.", True)
download_file(apple_support_url(), zipPath)
lastError = None
for sourceUrl in apple_support_urls():
try:
download_file(sourceUrl, zipPath)
break
except subprocess.CalledProcessError as error:
lastError = error
zipPath.unlink(missing_ok=True)
else:
raise RuntimeError("Apple 2e support archive could not be downloaded.") from lastError
if sha256_file(zipPath) != APPLE2E_ZIP_SHA256:
zipPath.unlink(missing_ok=True)