Skip to content

Commit c3ad639

Browse files
committed
Auto merge of #13614 - ehuss:fix-cdn-publish, r=weihanglo
Fix publish script due to crates.io CDN change Now that crates.io goes directly to the CDN, this has changed the HTTP response code when a crate is not found (from 404 to 403). This updates the publish script to handle more error codes to assume something isn't published. This also updates it to go directly to the endpoint instead of through the crates.io redirect.
2 parents d2fbe57 + 97d896f commit c3ad639

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

publish.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,15 @@
3131

3232

3333
def already_published(name, version):
34+
url = f'https://static.crates.io/crates/{name}/{version}/download'
3435
try:
35-
urllib.request.urlopen('https://crates.io/api/v1/crates/%s/%s/download' % (name, version))
36+
urllib.request.urlopen(url)
3637
except HTTPError as e:
37-
if e.code == 404:
38+
# 403 and 404 are common responses to assume it is not published
39+
if 400 <= e.code < 500:
3840
return False
41+
print(f'error: failed to check if {name} {version} is already published')
42+
print(f' HTTP response error code {e.code} checking {url}')
3943
raise
4044
return True
4145

0 commit comments

Comments
 (0)