From d63a2fc22f9df562374ed3cf7b678deb0f9efa98 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Wed, 2 Aug 2023 22:09:24 +0200 Subject: use fallback filename if no title is set --- fietsboek/views/detail.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fietsboek/views/detail.py b/fietsboek/views/detail.py index 8e296b7..d00aed3 100644 --- a/fietsboek/views/detail.py +++ b/fietsboek/views/detail.py @@ -97,7 +97,10 @@ def gpx(request): except FileNotFoundError: LOGGER.error("Track exists in database, but not on disk: %d", track.id) return HTTPInternalServerError() - wanted_filename = f"{track.id} - {util.secure_filename(track.title)}.gpx" + if track.title: + wanted_filename = f"{track.id} - {util.secure_filename(track.title)}.gpx" + else: + wanted_filename = f"{track.id}.gpx" content_disposition = f'attachment; filename="{wanted_filename}"' # We can be nice to the client if they support it, and deliver the gzipped # data straight. This saves decompression time on the server and saves a -- cgit v1.2.3