Skip to content

Commit a3b9a4f

Browse files
committed
Run updates in parallel
Signed-off-by: Florian Grabmeier <[email protected]>
1 parent 8180c1c commit a3b9a4f

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

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

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -321,34 +321,33 @@ await Http.DownloadAsync(x.PluginNewUserPlugin.UrlDownload, downloadToFilePath)
321321
Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
322322
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
323323
{
324-
foreach (var plugin in resultsForUpdate)
324+
Parallel.ForEach(resultsForUpdate, plugin =>
325325
{
326-
var downloadToFilePath = Path.Combine(Path.GetTempPath(),
327-
$"{plugin.Name}-{plugin.NewVersion}.zip");
326+
var downloadToFilePath = Path.Combine(Path.GetTempPath(), $"{plugin.Name}-{plugin.NewVersion}.zip");
328327

329328
_ = Task.Run(async delegate
329+
{
330+
if (File.Exists(downloadToFilePath))
330331
{
331-
if (File.Exists(downloadToFilePath))
332-
{
333-
File.Delete(downloadToFilePath);
334-
}
332+
File.Delete(downloadToFilePath);
333+
}
335334

336-
await Http.DownloadAsync(plugin.PluginNewUserPlugin.UrlDownload, downloadToFilePath)
337-
.ConfigureAwait(false);
335+
await Http.DownloadAsync(plugin.PluginNewUserPlugin.UrlDownload, downloadToFilePath)
336+
.ConfigureAwait(false);
338337

339-
PluginManager.UpdatePlugin(plugin.PluginExistingMetadata, plugin.PluginNewUserPlugin, downloadToFilePath);
338+
PluginManager.UpdatePlugin(plugin.PluginExistingMetadata, plugin.PluginNewUserPlugin, downloadToFilePath);
340339

341-
}).ContinueWith(t =>
342-
{
343-
Log.Exception("PluginsManager", $"Update failed for {plugin.Name}",
344-
t.Exception.InnerException);
345-
Context.API.ShowMsg(
346-
Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"),
347-
string.Format(
348-
Context.API.GetTranslation("plugin_pluginsmanager_install_error_subtitle"),
349-
plugin.Name));
350-
}, TaskContinuationOptions.OnlyOnFaulted);
351-
}
340+
}).ContinueWith(t =>
341+
{
342+
Log.Exception("PluginsManager", $"Update failed for {plugin.Name}",
343+
t.Exception.InnerException);
344+
Context.API.ShowMsg(
345+
Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"),
346+
string.Format(
347+
Context.API.GetTranslation("plugin_pluginsmanager_install_error_subtitle"),
348+
plugin.Name));
349+
}, TaskContinuationOptions.OnlyOnFaulted);
350+
});
352351

353352
if (Settings.AutoRestartAfterChanging)
354353
{

0 commit comments

Comments
 (0)