mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 22:11:14 +02:00
When exporting project raise error if export is not possible
This commit is contained in:
3 files changed
+50
-9
No files matched your search
@@ -231,14 +231,21 @@ class ProjectHandler:
|
||||
controller = Controller.instance()
|
||||
project = controller.get_project(request.match_info["project_id"])
|
||||
|
||||
response.content_type = 'application/gns3project'
|
||||
response.headers['CONTENT-DISPOSITION'] = 'attachment; filename="{}.gns3project"'.format(project.name)
|
||||
response.enable_chunked_encoding()
|
||||
# Very important: do not send a content length otherwise QT closes the connection (curl can consume the feed)
|
||||
response.content_length = None
|
||||
response.start(request)
|
||||
|
||||
started = False
|
||||
|
||||
for data in project.export(include_images=bool(request.GET.get("include_images", "0"))):
|
||||
# We need to do that now because export could failed and raise an HTTP error
|
||||
# that why response start need to be the later possible
|
||||
if not started:
|
||||
response.content_type = 'application/gns3project'
|
||||
response.headers['CONTENT-DISPOSITION'] = 'attachment; filename="{}.gns3project"'.format(project.name)
|
||||
response.enable_chunked_encoding()
|
||||
# Very important: do not send a content length otherwise QT closes the connection (curl can consume the feed)
|
||||
response.content_length = None
|
||||
response.start(request)
|
||||
started = True
|
||||
|
||||
response.write(data)
|
||||
yield from response.drain()
|
||||
|
||||
|
||||
Reference in new issue
Block a user