Returning a 404 if the download key is invalid

This commit is contained in:
Darren Burns
2024-08-07 14:34:13 +01:00
parent 24a24b34f2
commit efe1c893e2

View File

@@ -156,7 +156,11 @@ class Server:
"""Handle a download request."""
key = request.match_info["key"]
download_meta = await self.download_manager.get_download_metadata(key)
try:
download_meta = await self.download_manager.get_download_metadata(key)
except KeyError:
raise web.HTTPNotFound(text=f"Download with key {key!r} not found")
download_stream = self.download_manager.download(key)
response = web.StreamResponse()