From dd8d8bc51717455b7bce4d0976ce96f56f54cea0 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Sun, 18 Aug 2024 15:09:02 -0500 Subject: [PATCH] Addon Manager: Fix ZIP installation Always delete the old version before installing the new one --- src/Mod/AddonManager/addonmanager_installer.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Mod/AddonManager/addonmanager_installer.py b/src/Mod/AddonManager/addonmanager_installer.py index ab3131d70c..d3f2f7de1b 100644 --- a/src/Mod/AddonManager/addonmanager_installer.py +++ b/src/Mod/AddonManager/addonmanager_installer.py @@ -377,6 +377,12 @@ class AddonInstaller(QtCore.QObject): subdirectory of the main directory.""" destination = os.path.join(self.installation_path, self.addon_to_install.name) + if os.path.exists(destination): + remove_succeeded = utils.rmdir(destination) + if not remove_succeeded: + FreeCAD.Console.PrintError(f"Failed to remove {destination}, aborting update") + raise RuntimeError(f"Failed to remove outdated Addon from {destination}") + with zipfile.ZipFile(filename, "r") as zfile: zfile.extractall(destination)