1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 17:28:08 +00:00

Avoid crash due to persmission error on the .backup file

This commit is contained in:
Julien Duponchelle 2016-11-18 17:17:14 +01:00
parent 8ad5670eeb
commit 5ab85e5c9e
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

View File

@ -609,7 +609,7 @@ class Project:
def _topology_file(self):
return os.path.join(self.path, self._filename)
@asyncio.coroutine
@locked_coroutine
def open(self):
"""
Load topology elements
@ -623,7 +623,10 @@ class Project:
path = self._topology_file()
if not os.path.exists(path):
return
shutil.copy(path, path + ".backup")
try:
shutil.copy(path, path + ".backup")
except OSError:
pass
try:
topology = load_topology(path)["topology"]
for compute in topology.get("computes", []):
@ -649,10 +652,14 @@ class Project:
# We don't care if a compute is down at this step
except (ComputeError, aiohttp.web.HTTPNotFound, aiohttp.web.HTTPConflict):
pass
shutil.copy(path + ".backup", path)
if os.path.exists(path + ".backup"):
shutil.copy(path + ".backup", path)
self._status = "closed"
raise e
os.remove(path + ".backup")
try:
os.remove(path + ".backup")
except OSError:
pass
# Should we start the nodes when project is open
if self._auto_start: