Skip to content

Commit 54a60d0

Browse files
committed
Fix publish script due to crates.io CDN change
1 parent 2fe739f commit 54a60d0

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)