From 4ced06473b062fac8583965a4a7dbd387da1b7ef Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Mon, 2 Jun 2025 15:29:50 +0200 Subject: [PATCH] Add initialization check to plugin download logic --- .../Tools/PluginSystem/PluginFactory.Download.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/MindWork AI Studio/Tools/PluginSystem/PluginFactory.Download.cs b/app/MindWork AI Studio/Tools/PluginSystem/PluginFactory.Download.cs index e29e503b..b8720bc9 100644 --- a/app/MindWork AI Studio/Tools/PluginSystem/PluginFactory.Download.cs +++ b/app/MindWork AI Studio/Tools/PluginSystem/PluginFactory.Download.cs @@ -6,13 +6,21 @@ public static partial class PluginFactory { public static async Task TryDownloadingConfigPluginAsync(Guid configPlugId, string configServerUrl, CancellationToken cancellationToken = default) { - LOG.LogInformation($"Downloading configuration plugin with ID: {configPlugId} from server: {configServerUrl}"); + if(!IS_INITIALIZED) + { + LOG.LogWarning("Plugin factory is not yet initialized. Cannot download configuration plugin."); + return false; + } + + var serverUrl = configServerUrl.EndsWith('/') ? configServerUrl[..^1] : configServerUrl; + var downloadUrl = $"{serverUrl}/{configPlugId}.zip"; + + LOG.LogInformation($"Try to download configuration plugin with ID='{configPlugId}' from server='{configServerUrl}' (GET {downloadUrl})"); var tempDownloadFile = Path.GetTempFileName(); try { using var httpClient = new HttpClient(); - var serverUrl = configServerUrl.EndsWith('/') ? configServerUrl[..^1] : configServerUrl; - var response = await httpClient.GetAsync($"{serverUrl}/{configPlugId}.zip", cancellationToken); + var response = await httpClient.GetAsync(downloadUrl, cancellationToken); if (response.IsSuccessStatusCode) { await using var tempFileStream = File.Create(tempDownloadFile);