Skip to content

Commit dda2c97

Browse files
committed
Recursively purge all download URLs
1 parent cb570fd commit dda2c97

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

run_release.py

+19-15
Original file line numberDiff line numberDiff line change
@@ -942,22 +942,26 @@ def purge_the_cdn(db: ReleaseShelf) -> None:
942942
"https://www.python.org/downloads/windows/",
943943
"https://www.python.org/downloads/macos/",
944944
]
945-
# Purge the source URLs and their associated metadata files.
946-
source_urls = [
947-
f"https://www.python.org/ftp/python/{normalized_release}/Python-{db['release']}.tgz",
948-
f"https://www.python.org/ftp/python/{normalized_release}/Python-{db['release']}.tar.xz",
949-
]
950-
for source_url in source_urls:
951-
urls.extend(
952-
[
953-
f"{source_url}",
954-
f"{source_url}.asc",
955-
f"{source_url}.crt",
956-
f"{source_url}.sig",
957-
f"{source_url}.sigstore",
958-
f"{source_url}.spdx.json",
959-
]
945+
946+
# Recursively discover artifacts to purge.
947+
ftp_download_pages = [f"https://www.python.org/ftp/python/{normalized_release}/"]
948+
while ftp_download_pages:
949+
ftp_download_page = ftp_download_pages.pop(0)
950+
req = urllib.request.Request(
951+
method="GET", url=ftp_download_page, headers=headers
960952
)
953+
resp = urllib.request.urlopen(req)
954+
if resp.code != 200:
955+
raise RuntimeError("Failed to purge the python.org/downloads CDN")
956+
for link in re.findall(r"<a href=\"([^\"]+)\">", resp.read().decode()):
957+
if link in ("../", "./"): # Special value, ignore it.
958+
continue
959+
960+
if link.endswith("/"): # Directory, recurse into it.
961+
ftp_download_pages.append(f"{ftp_download_page}{link}")
962+
963+
# We want to purge both directories and files.
964+
urls.append(f"{ftp_download_page}{link}")
961965

962966
for url in urls:
963967
req = urllib.request.Request(url=url, headers=headers, method="PURGE")

0 commit comments

Comments
 (0)