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

pull/1336/head
grossmj 6 years ago
parent 50a922f83e
commit 3b94484914

@ -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):

@ -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)

@ -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):

Loading…
Cancel
Save