From d2ad9dc5e2aa0a272f0b0176c0b540d18838d298 Mon Sep 17 00:00:00 2001 From: grossmj Date: Sun, 1 Jan 2023 17:49:00 +0800 Subject: [PATCH] Delete the built-in appliance directory before installing updated files --- gns3server/controller/__init__.py | 1 - gns3server/controller/appliance_manager.py | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gns3server/controller/__init__.py b/gns3server/controller/__init__.py index eb83d0dc..9f947673 100644 --- a/gns3server/controller/__init__.py +++ b/gns3server/controller/__init__.py @@ -318,7 +318,6 @@ class Controller: server_config = Config.instance().get_section_config("Server") configs_path = os.path.expanduser(server_config.get("configs_path", "~/GNS3/configs")) - # shutil.rmtree(configs_path, ignore_errors=True) os.makedirs(configs_path, exist_ok=True) return configs_path diff --git a/gns3server/controller/appliance_manager.py b/gns3server/controller/appliance_manager.py index 48362379..15c4da70 100644 --- a/gns3server/controller/appliance_manager.py +++ b/gns3server/controller/appliance_manager.py @@ -81,14 +81,15 @@ class ApplianceManager: os.makedirs(appliances_path, exist_ok=True) return appliances_path - def _builtin_appliances_path(self): + def _builtin_appliances_path(self, delete_first=False): """ Get the built-in appliance storage directory """ config = Config.instance() appliances_dir = os.path.join(config.config_dir, "appliances") - # shutil.rmtree(appliances_dir, ignore_errors=True) + if delete_first: + shutil.rmtree(appliances_dir, ignore_errors=True) os.makedirs(appliances_dir, exist_ok=True) return appliances_dir @@ -97,7 +98,7 @@ class ApplianceManager: At startup we copy the built-in appliances files. """ - dst_path = self._builtin_appliances_path() + dst_path = self._builtin_appliances_path(delete_first=True) log.info(f"Installing built-in appliances in '{dst_path}'") try: if hasattr(sys, "frozen") and sys.platform.startswith("win"):