1
0
mirror of https://github.com/GNS3/gns3-server synced 2025-07-06 14:52:37 +00:00

Fix BadZipFile: File is not a zip file

This commit is contained in:
Julien Duponchelle 2016-10-03 10:33:56 +02:00
parent bfb82a9618
commit 420168015c
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

View File

@ -52,6 +52,7 @@ def import_project(controller, project_id, stream, location=None, name=None, kee
if location and ".gns3" in location: if location and ".gns3" in location:
raise aiohttp.web.HTTPConflict(text="The destination path should not contain .gns3") raise aiohttp.web.HTTPConflict(text="The destination path should not contain .gns3")
try:
with zipfile.ZipFile(stream) as myzip: with zipfile.ZipFile(stream) as myzip:
try: try:
@ -144,6 +145,8 @@ def import_project(controller, project_id, stream, location=None, name=None, kee
project = yield from controller.load_project(dot_gns3_path, load=False) project = yield from controller.load_project(dot_gns3_path, load=False)
return project return project
except zipfile.BadZipFile:
raise aiohttp.web.HTTPConflict(text="Can't import topology the file is corrupted or not a GNS3 project (invalid zip)")
def _move_node_file(path, old_id, new_id): def _move_node_file(path, old_id, new_id):