Delete the built-in appliance directory before installing updated files

This commit is contained in:
grossmj 2023-01-01 17:49:00 +08:00
parent 5bccf4841d
commit d2ad9dc5e2
2 changed files with 4 additions and 4 deletions

View File

@ -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

View File

@ -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"):