mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-04 06:21:15 +02:00
Disallow to modify a template if changes cannot be written on disk. Fixes #1695
This commit is contained in:
1 parent
a47fa83cec
commit
98f5454ccb
3 files changed
+22
-3
No files matched your search
@@ -132,6 +132,20 @@ class Controller:
|
||||
self._computes = {}
|
||||
self._projects = {}
|
||||
|
||||
def check_can_write_config(self):
|
||||
"""
|
||||
Check if the controller configuration can be written on disk
|
||||
|
||||
:returns: boolean
|
||||
"""
|
||||
|
||||
try:
|
||||
os.makedirs(os.path.dirname(self._config_file), exist_ok=True)
|
||||
if not os.access(self._config_file, os.W_OK):
|
||||
raise aiohttp.web.HTTPConflict(text="Change rejected, cannot write to controller configuration file '{}'".format(self._config_file))
|
||||
except OSError as e:
|
||||
raise aiohttp.web.HTTPConflict(text="Change rejected: {}".format(e))
|
||||
|
||||
def save(self):
|
||||
"""
|
||||
Save the controller configuration on disk
|
||||
|
||||
Reference in new issue
Block a user