From 9dc713f31db226496c78640060d64a0c90480c7b Mon Sep 17 00:00:00 2001 From: Jeremy Date: Wed, 25 Feb 2015 17:38:36 -0700 Subject: [PATCH] Fixes race condition when deleting empty legacy project files dir. --- gns3server/modules/base_manager.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/gns3server/modules/base_manager.py b/gns3server/modules/base_manager.py index 41e63ced..8845d4cb 100644 --- a/gns3server/modules/base_manager.py +++ b/gns3server/modules/base_manager.py @@ -177,20 +177,14 @@ class BaseManager: raise aiohttp.web.HTTPInternalServerError(text="Could not move VM working directory: {} to {} {}".format(vm_working_dir, new_vm_working_dir, e)) try: - if not os.listdir(module_path): - os.rmdir(module_path) - except OSError as e: - raise aiohttp.web.HTTPInternalServerError(text="Could not delete {}: {}".format(module_path, e)) - except FileNotFoundError as e: - log.warning(e) + os.rmdir(module_path) + except OSError: + pass try: - if not os.listdir(project_files_dir): - os.rmdir(project_files_dir) - except OSError as e: - raise aiohttp.web.HTTPInternalServerError(text="Could not delete {}: {}".format(project_files_dir, e)) - except FileNotFoundError as e: - log.warning(e) + os.rmdir(project_files_dir) + except OSError: + pass if not vm_id: vm_id = str(uuid4())