Skip to content

Commit

Permalink
Fix publish script due to crates.io CDN change
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Mar 21, 2024
1 parent 2fe739f commit 54a60d0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@


def already_published(name, version):
url = f'https://static.crates.io/crates/{name}/{version}/download'
try:
urllib.request.urlopen('https://crates.io/api/v1/crates/%s/%s/download' % (name, version))
urllib.request.urlopen(url)
except HTTPError as e:
if e.code == 404:
# 403 and 404 are common responses to assume it is not published
if 400 <= e.code < 500:
return False
print(f'error: failed to check if {name} {version} is already published')
print(f' HTTP response error code {e.code} checking {url}')
raise
return True

Expand Down

0 comments on commit 54a60d0

Please sign in to comment.