Addon Manager: Fix ZIP installation

Always delete the old version before installing the new one
This commit is contained in:
Chris Hennes
2024-08-18 15:09:02 -05:00
committed by WandererFan
parent 7cce01368c
commit dd8d8bc517

View File

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