mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-26 16:58:28 +00:00
Catch error when a file is deleted during the compression of project
Fix #860
This commit is contained in:
parent
666461277d
commit
e0071f5b59
@ -696,13 +696,16 @@ class Project:
|
|||||||
if self._status == "closed":
|
if self._status == "closed":
|
||||||
yield from self.open()
|
yield from self.open()
|
||||||
|
|
||||||
with tempfile.TemporaryDirectory() as tmpdir:
|
try:
|
||||||
zipstream = yield from export_project(self, tmpdir, keep_compute_id=True, allow_all_nodes=True)
|
with tempfile.TemporaryDirectory() as tmpdir:
|
||||||
with open(os.path.join(tmpdir, "project.gns3p"), "wb+") as f:
|
zipstream = yield from export_project(self, tmpdir, keep_compute_id=True, allow_all_nodes=True)
|
||||||
for data in zipstream:
|
with open(os.path.join(tmpdir, "project.gns3p"), "wb+") as f:
|
||||||
f.write(data)
|
for data in zipstream:
|
||||||
with open(os.path.join(tmpdir, "project.gns3p"), "rb") as f:
|
f.write(data)
|
||||||
project = yield from import_project(self._controller, str(uuid.uuid4()), f, location=location, name=name, keep_compute_id=True)
|
with open(os.path.join(tmpdir, "project.gns3p"), "rb") as f:
|
||||||
|
project = yield from import_project(self._controller, str(uuid.uuid4()), f, location=location, name=name, keep_compute_id=True)
|
||||||
|
except OSError as e:
|
||||||
|
raise aiohttp.web.HTTPConflict(text="Can not duplicate project: {}".format(str(e)))
|
||||||
|
|
||||||
if previous_status == "closed":
|
if previous_status == "closed":
|
||||||
yield from self.close()
|
yield from self.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user