Skip to content

Commit cc921c7

Browse files
committed
Improve progress box when exception happens
1 parent 297d191 commit cc921c7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ internal async Task InstallOrUpdateAsync(UserPlugin plugin)
145145
var filePath = Path.Combine(Path.GetTempPath(), downloadFilename);
146146

147147
var downloadCancelled = false;
148+
var exceptionHappened = false;
148149
try
149150
{
150151
if (!plugin.IsFromLocalInstallPath)
@@ -168,8 +169,10 @@ await Context.API.ShowProgressBoxAsync(prgBoxTitle,
168169
{
169170
if (reportProgress == null)
170171
{
171-
// cannot use progress box
172-
await Http.DownloadAsync(plugin.UrlDownload, filePath).ConfigureAwait(false);
172+
// when reportProgress is null, it means there is expcetion with the progress box
173+
// so we record it with exceptionHappened and return so that progress box will close instantly
174+
exceptionHappened = true;
175+
return;
173176
}
174177
else
175178
{
@@ -200,6 +203,11 @@ await Context.API.ShowProgressBoxAsync(prgBoxTitle,
200203
cts.Cancel();
201204
downloadCancelled = true;
202205
});
206+
207+
// if exception happened while downloading and user does not cancel downloading,
208+
// we need to redownload the plugin
209+
if (exceptionHappened && (!downloadCancelled))
210+
await Http.DownloadAsync(plugin.UrlDownload, filePath).ConfigureAwait(false);
203211
}
204212
else
205213
{

0 commit comments

Comments
 (0)