1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-12 19:38:57 +00:00

Fix bug with export project. Ref #1187 #1307.

This commit is contained in:
grossmj 2018-04-28 16:38:52 +07:00
parent 50a922f83e
commit 3b94484914
3 changed files with 5 additions and 4 deletions

View File

@ -198,8 +198,7 @@ def _patch_project_file(project, path, zstream, include_images, keep_compute_id,
for compute_id, image_type, image in remote_images:
yield from _export_remote_images(project, compute_id, image_type, image, zstream, temporary_dir)
zstream.writestr("project.gns3", json.dumps(topology).encode())
zstream.writestr("project.gns3", json.dumps(topology).encode())
return images
def _export_local_image(image, zstream):

View File

@ -57,7 +57,9 @@ def import_project(controller, project_id, stream, location=None, name=None, kee
with zipfile.ZipFile(stream) as zip_file:
project_file = zip_file.read("project.gns3").decode()
except zipfile.BadZipFile:
raise aiohttp.web.HTTPConflict(text="Cannot import project, not a GNS3 project (invalid zip) or project.gns3 file could not be found")
raise aiohttp.web.HTTPConflict(text="Cannot import project, not a GNS3 project (invalid zip)")
except KeyError:
raise aiohttp.web.HTTPConflict(text="Cannot import project, project.gns3 file could not be found")
try:
topology = json.loads(project_file)

View File

@ -123,8 +123,8 @@ class Snapshot:
project = yield from import_project(self._project.controller, self._project.id, f, location=self._project.path)
except (OSError, PermissionError) as e:
raise aiohttp.web.HTTPConflict(text=str(e))
self._project.controller.notification.emit("snapshot.restored", self.__json__())
yield from project.open()
self._project.controller.notification.emit("snapshot.restored", self.__json__())
return self._project
def __json__(self):