From 175f4b51e5d4ade9a35e35276c989c7a96fcf3b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Tue, 7 Nov 2023 16:47:34 +0100 Subject: [PATCH] fix: Avoid exception when downloading a non-existent file --- website/web/genericapi.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/website/web/genericapi.py b/website/web/genericapi.py index a0aba5d..af97021 100644 --- a/website/web/genericapi.py +++ b/website/web/genericapi.py @@ -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())