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

Atomic save of the .gns3

Fix #579
This commit is contained in:
Julien Duponchelle 2016-06-17 17:13:36 +02:00
parent 627ebdb322
commit 49eb7d8ce7
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

View File

@ -363,8 +363,9 @@ class Project:
topo = project_to_topology(self) topo = project_to_topology(self)
path = self._topology_file() path = self._topology_file()
log.debug("Write %s", path) log.debug("Write %s", path)
with open(path, "w+") as f: with open(path + ".tmp", "w+") as f:
json.dump(topo, f, indent=4, sort_keys=True) json.dump(topo, f, indent=4, sort_keys=True)
shutil.move(path + ".tmp", path)
except OSError as e: except OSError as e:
raise aiohttp.web.HTTPInternalServerError(text="Could not write topology: {}".format(e)) raise aiohttp.web.HTTPInternalServerError(text="Could not write topology: {}".format(e))