Avoid crash due to persmission error on the .backup file

pull/794/head
Julien Duponchelle 8 years ago
parent 8ad5670eeb
commit 5ab85e5c9e
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

@ -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…
Cancel
Save