mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
Copying project files directly, rather than copying them in an import-export fashion, can make copying projects many times faster
This commit is contained in:
1 parent
5ffe5fd9b3
commit
2dbde5df22
2 files changed
+3
-20
No files matched your search
@@ -42,9 +42,11 @@ from ..utils.application_id import get_next_application_id
|
||||
from ..utils.asyncio.pool import Pool
|
||||
from ..utils.asyncio import locking
|
||||
from ..utils.asyncio import aiozipstream
|
||||
from ..utils.asyncio import wait_run_in_executor
|
||||
from .export_project import export_project
|
||||
from .import_project import import_project
|
||||
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -1262,11 +1264,7 @@ class Project:
|
||||
new_project_id = str(uuid.uuid4())
|
||||
new_project_path = p_work.joinpath(new_project_id)
|
||||
# copy dir
|
||||
scripts_path = os.path.join(pathlib.Path(__file__).resolve().parent.parent.parent, 'scripts')
|
||||
process = await asyncio.create_subprocess_exec('python', os.path.join(scripts_path, 'copy_tree.py'), '--src',
|
||||
self.path, '--dst',
|
||||
new_project_path.as_posix())
|
||||
await process.wait()
|
||||
await wait_run_in_executor(shutil.copytree, self.path, new_project_path.as_posix())
|
||||
log.info("[FAST] Copy project: {} to: '{}', cost={}s".format(self.path, new_project_path, time.time() - t0))
|
||||
topology = json.loads(new_project_path.joinpath('{}.gns3'.format(self.name)).read_bytes())
|
||||
project_name = name or topology["name"]
|
||||
|
||||
Reference in new issue
Block a user