From 3b94484914448c5f3a7a1f66a175923860b09c0a Mon Sep 17 00:00:00 2001 From: grossmj Date: Sat, 28 Apr 2018 16:38:52 +0700 Subject: [PATCH] Fix bug with export project. Ref #1187 #1307. --- gns3server/controller/export_project.py | 3 +-- gns3server/controller/import_project.py | 4 +++- gns3server/controller/snapshot.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gns3server/controller/export_project.py b/gns3server/controller/export_project.py index 82c0d4da..37faaf38 100644 --- a/gns3server/controller/export_project.py +++ b/gns3server/controller/export_project.py @@ -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): diff --git a/gns3server/controller/import_project.py b/gns3server/controller/import_project.py index 97eed7d6..a5a89661 100644 --- a/gns3server/controller/import_project.py +++ b/gns3server/controller/import_project.py @@ -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) diff --git a/gns3server/controller/snapshot.py b/gns3server/controller/snapshot.py index 6061c1a0..70c3d173 100644 --- a/gns3server/controller/snapshot.py +++ b/gns3server/controller/snapshot.py @@ -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):