fix: Avoid exception when downloading a non-existent file

pull/829/head
Raphaël Vinot 2023-11-07 16:47:34 +01:00
parent 7536bbb7f2
commit 175f4b51e5
1 changed files with 4 additions and 0 deletions

View File

@ -472,6 +472,10 @@ class CaptureData(Resource):
@api.produces(['application/zip'])
def get(self, capture_uuid: str):
filename, data = lookyloo.get_data(capture_uuid)
if not filename:
# This capture didn't trigger a download.
filename = 'no_download'
data = BytesIO(b"This capture didn't trigger a download")
to_return = BytesIO()
with ZipFile(to_return, 'w') as z:
z.writestr(filename, data.getvalue())