mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-08-24 20:52:11 +00:00
Fixed deletion of the existing assistant plugin when its backup failed
This commit is contained in:
parent
e0057b67ae
commit
c50ca0dd54
@ -427,6 +427,7 @@ public sealed class AssistantPluginInstallService
|
|||||||
string? backupDirectory = null;
|
string? backupDirectory = null;
|
||||||
string? finalDirectory = null;
|
string? finalDirectory = null;
|
||||||
var replacedExisting = false;
|
var replacedExisting = false;
|
||||||
|
var movedIntoPlace = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -443,6 +444,7 @@ public sealed class AssistantPluginInstallService
|
|||||||
}
|
}
|
||||||
|
|
||||||
Directory.Move(stagingDirectory, finalDirectory);
|
Directory.Move(stagingDirectory, finalDirectory);
|
||||||
|
movedIntoPlace = true;
|
||||||
await PluginFactory.LoadAll(token);
|
await PluginFactory.LoadAll(token);
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(backupDirectory))
|
if (!string.IsNullOrWhiteSpace(backupDirectory))
|
||||||
@ -455,7 +457,10 @@ public sealed class AssistantPluginInstallService
|
|||||||
{
|
{
|
||||||
this.logger.LogError(e, "Failed to install assistant plugin.");
|
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);
|
TryDeleteDirectory(finalDirectory, "failed assistant plugin installation", this.logger);
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(backupDirectory) && Directory.Exists(backupDirectory) && !string.IsNullOrWhiteSpace(finalDirectory) && !Directory.Exists(finalDirectory))
|
if (!string.IsNullOrWhiteSpace(backupDirectory) && Directory.Exists(backupDirectory) && !string.IsNullOrWhiteSpace(finalDirectory) && !Directory.Exists(finalDirectory))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user