Run updates in parallel

Signed-off-by: Florian Grabmeier <flo.grabmeier@gmail.com>
This commit is contained in:
Florian Grabmeier 2023-11-22 14:55:53 +01:00
parent 8180c1cd40
commit a3b9a4f9d0

View file

@ -321,34 +321,33 @@ namespace Flow.Launcher.Plugin.PluginsManager
Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
foreach (var plugin in resultsForUpdate)
Parallel.ForEach(resultsForUpdate, plugin =>
{
var downloadToFilePath = Path.Combine(Path.GetTempPath(),
$"{plugin.Name}-{plugin.NewVersion}.zip");
var downloadToFilePath = Path.Combine(Path.GetTempPath(), $"{plugin.Name}-{plugin.NewVersion}.zip");
_ = Task.Run(async delegate
{
if (File.Exists(downloadToFilePath))
{
if (File.Exists(downloadToFilePath))
{
File.Delete(downloadToFilePath);
}
File.Delete(downloadToFilePath);
}
await Http.DownloadAsync(plugin.PluginNewUserPlugin.UrlDownload, downloadToFilePath)
.ConfigureAwait(false);
await Http.DownloadAsync(plugin.PluginNewUserPlugin.UrlDownload, downloadToFilePath)
.ConfigureAwait(false);
PluginManager.UpdatePlugin(plugin.PluginExistingMetadata, plugin.PluginNewUserPlugin, downloadToFilePath);
PluginManager.UpdatePlugin(plugin.PluginExistingMetadata, plugin.PluginNewUserPlugin, downloadToFilePath);
}).ContinueWith(t =>
{
Log.Exception("PluginsManager", $"Update failed for {plugin.Name}",
t.Exception.InnerException);
Context.API.ShowMsg(
Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"),
string.Format(
Context.API.GetTranslation("plugin_pluginsmanager_install_error_subtitle"),
plugin.Name));
}, TaskContinuationOptions.OnlyOnFaulted);
}
}).ContinueWith(t =>
{
Log.Exception("PluginsManager", $"Update failed for {plugin.Name}",
t.Exception.InnerException);
Context.API.ShowMsg(
Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"),
string.Format(
Context.API.GetTranslation("plugin_pluginsmanager_install_error_subtitle"),
plugin.Name));
}, TaskContinuationOptions.OnlyOnFaulted);
});
if (Settings.AutoRestartAfterChanging)
{