From c50ca0dd54c211b8b00f20c7c678faf6c0c74335 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Wed, 5 Aug 2026 16:22:59 +0200 Subject: [PATCH] Fixed deletion of the existing assistant plugin when its backup failed --- .../Tools/Services/AssistantPluginInstallService.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/MindWork AI Studio/Tools/Services/AssistantPluginInstallService.cs b/app/MindWork AI Studio/Tools/Services/AssistantPluginInstallService.cs index 4c16f5dc..2baf60ce 100644 --- a/app/MindWork AI Studio/Tools/Services/AssistantPluginInstallService.cs +++ b/app/MindWork AI Studio/Tools/Services/AssistantPluginInstallService.cs @@ -427,6 +427,7 @@ public sealed class AssistantPluginInstallService string? backupDirectory = null; string? finalDirectory = null; var replacedExisting = false; + var movedIntoPlace = false; try { @@ -443,6 +444,7 @@ public sealed class AssistantPluginInstallService } Directory.Move(stagingDirectory, finalDirectory); + movedIntoPlace = true; await PluginFactory.LoadAll(token); if (!string.IsNullOrWhiteSpace(backupDirectory)) @@ -455,7 +457,10 @@ public sealed class AssistantPluginInstallService { this.logger.LogError(e, "Failed to install assistant plugin."); - if (!string.IsNullOrWhiteSpace(finalDirectory) && Directory.Exists(finalDirectory)) + // Only remove the target directory when this installation actually moved the plugin + // there. Otherwise, when moving the previous plugin into the backup directory failed, + // we would delete the still intact previous plugin: + if (movedIntoPlace && !string.IsNullOrWhiteSpace(finalDirectory) && Directory.Exists(finalDirectory)) TryDeleteDirectory(finalDirectory, "failed assistant plugin installation", this.logger); if (!string.IsNullOrWhiteSpace(backupDirectory) && Directory.Exists(backupDirectory) && !string.IsNullOrWhiteSpace(finalDirectory) && !Directory.Exists(finalDirectory))