Skip to content

Commit

Permalink
add cloudflare detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Androz2091 committed Mar 15, 2024
1 parent c18f9bb commit b93ca75
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def download_file(package_status_id, package_id, link, session):
if not check_whitelisted_link(link):
print('checking content type')
r = requests.head(link, allow_redirects=True)
if r.status_code != 200 or 'content-type' not in r.headers or 'application/octet-stream' not in r.headers['content-type']:
# check if location starts with https://storage.googleapis.com after 302
if r.status_code != 302 and not r.headers['Location'].startswith('https://storage.googleapis.com'):
print('The link does not point to a valid file.')
raise Exception('INVALID_LINK')

Expand Down

0 comments on commit b93ca75

Please sign in to comment.