mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-01-31 08:25:33 +00:00
Avoid crash due to persmission error on the .backup file
This commit is contained in:
parent
8ad5670eeb
commit
5ab85e5c9e
@ -609,7 +609,7 @@ class Project:
|
|||||||
def _topology_file(self):
|
def _topology_file(self):
|
||||||
return os.path.join(self.path, self._filename)
|
return os.path.join(self.path, self._filename)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@locked_coroutine
|
||||||
def open(self):
|
def open(self):
|
||||||
"""
|
"""
|
||||||
Load topology elements
|
Load topology elements
|
||||||
@ -623,7 +623,10 @@ class Project:
|
|||||||
path = self._topology_file()
|
path = self._topology_file()
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
return
|
return
|
||||||
shutil.copy(path, path + ".backup")
|
try:
|
||||||
|
shutil.copy(path, path + ".backup")
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
try:
|
try:
|
||||||
topology = load_topology(path)["topology"]
|
topology = load_topology(path)["topology"]
|
||||||
for compute in topology.get("computes", []):
|
for compute in topology.get("computes", []):
|
||||||
@ -649,10 +652,14 @@ class Project:
|
|||||||
# We don't care if a compute is down at this step
|
# We don't care if a compute is down at this step
|
||||||
except (ComputeError, aiohttp.web.HTTPNotFound, aiohttp.web.HTTPConflict):
|
except (ComputeError, aiohttp.web.HTTPNotFound, aiohttp.web.HTTPConflict):
|
||||||
pass
|
pass
|
||||||
shutil.copy(path + ".backup", path)
|
if os.path.exists(path + ".backup"):
|
||||||
|
shutil.copy(path + ".backup", path)
|
||||||
self._status = "closed"
|
self._status = "closed"
|
||||||
raise e
|
raise e
|
||||||
os.remove(path + ".backup")
|
try:
|
||||||
|
os.remove(path + ".backup")
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
# Should we start the nodes when project is open
|
# Should we start the nodes when project is open
|
||||||
if self._auto_start:
|
if self._auto_start:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user