From f50b872f6acf5d2f5f75c487b8392d3abb8ebf3c Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Tue, 28 Apr 2026 19:46:15 -0400 Subject: [PATCH] Redundancy for some downloads. --- home/stormux/.local/bin/apple_2e.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/home/stormux/.local/bin/apple_2e.py b/home/stormux/.local/bin/apple_2e.py index 4019064..2e1bab1 100755 --- a/home/stormux/.local/bin/apple_2e.py +++ b/home/stormux/.local/bin/apple_2e.py @@ -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)