From b673b898a8c2ea0f9b7074f51d1a7ad5a3555c9e Mon Sep 17 00:00:00 2001 From: Jeremy Date: Mon, 2 Mar 2015 13:04:30 -0700 Subject: [PATCH] Fixes problem when trying to convert VirtualBox projects without cloned VMs. --- gns3server/modules/base_manager.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/gns3server/modules/base_manager.py b/gns3server/modules/base_manager.py index d2d1c7f1..f6b43175 100644 --- a/gns3server/modules/base_manager.py +++ b/gns3server/modules/base_manager.py @@ -181,12 +181,13 @@ class BaseManager: legacy_vm_dir = self.get_legacy_vm_workdir(legacy_id, name) legacy_vm_working_path = os.path.join(new_project_files_path, legacy_vm_dir) new_vm_working_path = os.path.join(new_project_files_path, self.module_name.lower(), new_id) - try: - log.info('Moving "{}" to "{}"'.format(legacy_vm_working_path, new_vm_working_path)) - yield from wait_run_in_executor(shutil.move, legacy_vm_working_path, new_vm_working_path) - except OSError as e: - raise aiohttp.web.HTTPInternalServerError(text="Could not move VM working directory: {} to {} {}".format(legacy_vm_working_path, - new_vm_working_path, e)) + if os.path.exists(legacy_vm_working_path) and not os.path.exists(new_vm_working_path): + try: + log.info('Moving "{}" to "{}"'.format(legacy_vm_working_path, new_vm_working_path)) + yield from wait_run_in_executor(shutil.move, legacy_vm_working_path, new_vm_working_path) + except OSError as e: + raise aiohttp.web.HTTPInternalServerError(text="Could not move VM working directory: {} to {} {}".format(legacy_vm_working_path, + new_vm_working_path, e)) return new_id