From cc921c7d291b45b4128cdb2b1423a2631a6ee422 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Fri, 10 Jan 2025 19:17:54 +0800 Subject: [PATCH] Improve progress box when exception happens --- .../PluginsManager.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs index c3ed04a4d..b6495d8f2 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs @@ -145,6 +145,7 @@ namespace Flow.Launcher.Plugin.PluginsManager var filePath = Path.Combine(Path.GetTempPath(), downloadFilename); var downloadCancelled = false; + var exceptionHappened = false; try { if (!plugin.IsFromLocalInstallPath) @@ -168,8 +169,10 @@ namespace Flow.Launcher.Plugin.PluginsManager { if (reportProgress == null) { - // cannot use progress box - await Http.DownloadAsync(plugin.UrlDownload, filePath).ConfigureAwait(false); + // when reportProgress is null, it means there is expcetion with the progress box + // so we record it with exceptionHappened and return so that progress box will close instantly + exceptionHappened = true; + return; } else { @@ -200,6 +203,11 @@ namespace Flow.Launcher.Plugin.PluginsManager cts.Cancel(); downloadCancelled = true; }); + + // if exception happened while downloading and user does not cancel downloading, + // we need to redownload the plugin + if (exceptionHappened && (!downloadCancelled)) + await Http.DownloadAsync(plugin.UrlDownload, filePath).ConfigureAwait(false); } else {