mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-04 14:31:13 +02:00
Cleanup the temporary project after modules have been notified of the
path change
This commit is contained in:
1 parent
528bb7a7c6
commit
c98bcedd39
4 files changed
+40
-12
No files matched your search
@@ -84,9 +84,11 @@ class ProjectHandler:
|
||||
project.name = request.json.get("name", project.name)
|
||||
project_path = request.json.get("path", project.path)
|
||||
if project_path != project.path:
|
||||
old_path = project.path
|
||||
project.path = project_path
|
||||
for module in MODULES:
|
||||
yield from module.instance().project_moved(project)
|
||||
yield from project.clean_old_path(old_path)
|
||||
# Very important we need to remove temporary flag after moving the project
|
||||
project.temporary = request.json.get("temporary", project.temporary)
|
||||
response.json(project)
|
||||
|
||||
@@ -146,11 +146,15 @@ class Project:
|
||||
self._path = path
|
||||
self._update_temporary_file()
|
||||
|
||||
# The order of operation is important because we want to avoid losing
|
||||
# data
|
||||
if old_path:
|
||||
@asyncio.coroutine
|
||||
def clean_old_path(self, old_path):
|
||||
"""
|
||||
Called after a project location change. All the modules should
|
||||
have been notified before
|
||||
"""
|
||||
if self._temporary:
|
||||
try:
|
||||
shutil.rmtree(old_path)
|
||||
yield from wait_run_in_executor(shutil.rmtree, old_path)
|
||||
except OSError as e:
|
||||
log.warn("Can't remove temporary directory {}: {}".format(old_path, e))
|
||||
|
||||
|
||||
Reference in new issue
Block a user