Fix error if regex can't find the filename (#3285)

* fix: treat error if regex doesn't match

* refactor: use assertion to avoid error message
This commit is contained in:
David Culley 2024-08-07 11:17:37 +02:00 committed by GitHub
parent a2b4b57390
commit 70a063a3b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1086,9 +1086,11 @@ def download_addon(client: HttpClient, id: int) -> DownloadOk | DownloadError:
data = client.stream_content(resp) data = client.stream_content(resp)
fname = re.match( match = re.match(
"attachment; filename=(.+)", resp.headers["content-disposition"] "attachment; filename=(.+)", resp.headers["content-disposition"]
).group(1) )
assert match is not None
fname = match.group(1)
meta = extract_meta_from_download_url(resp.url) meta = extract_meta_from_download_url(resp.url)