diff options
| author | Daniel Schadt <kingdread@gmx.de> | 2025-11-01 13:58:39 +0100 |
|---|---|---|
| committer | Daniel Schadt <kingdread@gmx.de> | 2025-11-01 13:58:39 +0100 |
| commit | cea67730a25376470dc34177865d09f319afcc08 (patch) | |
| tree | c7505822451a2edab6a51de7350cc2680d537428 | |
| parent | 04d1d18ec666525890398f196b6a148179c7d305 (diff) | |
| download | fietsboek-cea67730a25376470dc34177865d09f319afcc08.tar.gz fietsboek-cea67730a25376470dc34177865d09f319afcc08.tar.bz2 fietsboek-cea67730a25376470dc34177865d09f319afcc08.zip | |
fix archive download
| -rw-r--r-- | fietsboek/views/browse.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/fietsboek/views/browse.py b/fietsboek/views/browse.py index a01c015..c024828 100644 --- a/fietsboek/views/browse.py +++ b/fietsboek/views/browse.py @@ -534,12 +534,18 @@ def archive(request: Request) -> Response: if not track.is_visible_to(request.identity): return HTTPForbidden() + # Since we stream the data, we need to ensure it's loaded before we close + # the session + for track in tracks: + request.dbsession.refresh(track, ["points", "waypoints"]) + request.dbsession.expunge(track) + def generate(): stream = Stream() with ZipFile(stream, "w", ZIP_DEFLATED) as zipfile: # type: ignore - for track_id in track_ids: - data = request.data_manager.open(track_id).decompress_gpx() - zipfile.writestr(f"track_{track_id}.gpx", data) + for track in tracks: + data = track.gpx_xml() + zipfile.writestr(f"track_{track.id}.gpx", data) yield stream.readall() yield stream.readall() |
