diff --git a/Flow.Launcher.Infrastructure/Http/Http.cs b/Flow.Launcher.Infrastructure/Http/Http.cs index b7d274205..1d5f240e1 100644 --- a/Flow.Launcher.Infrastructure/Http/Http.cs +++ b/Flow.Launcher.Infrastructure/Http/Http.cs @@ -66,18 +66,12 @@ namespace Flow.Launcher.Infrastructure.Http response = response.NonNull(); var stream = response.GetResponseStream().NonNull(); - using (var reader = new StreamReader(stream, Encoding.GetEncoding(encoding))) - { - var content = await reader.ReadToEndAsync(); - if (response.StatusCode == HttpStatusCode.OK) - { - return content; - } - else - { - throw new HttpRequestException($"Error code <{response.StatusCode}> with content <{content}> returned from <{url}>"); - } - } + using var reader = new StreamReader(stream, Encoding.GetEncoding(encoding)); + var content = await reader.ReadToEndAsync(); + if (response.StatusCode != HttpStatusCode.OK) + throw new HttpRequestException($"Error code <{response.StatusCode}> with content <{content}> returned from <{url}>"); + + return content; } } } \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/Models/PluginsManifest.cs b/Plugins/Flow.Launcher.Plugin.PluginsManager/Models/PluginsManifest.cs index 134ad7bd0..290221710 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/Models/PluginsManifest.cs +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/Models/PluginsManifest.cs @@ -3,8 +3,7 @@ using Flow.Launcher.Infrastructure.Logger; using Newtonsoft.Json; using System; using System.Collections.Generic; -using System.Net; -using System.Text; +using System.Threading.Tasks; namespace Flow.Launcher.Plugin.PluginsManager.Models { @@ -12,24 +11,30 @@ namespace Flow.Launcher.Plugin.PluginsManager.Models { internal List UserPlugins { get; private set; } internal PluginsManifest() + { + DownloadManifest(); + } + + private void DownloadManifest() { var json = string.Empty; - - using (var wc = new WebClient { Proxy = Http.WebProxy() }) + try { - try - { - json = wc.DownloadString("https://raw.githubusercontent.com/Flow-Launcher/Flow.Launcher.PluginsManifest/main/plugins.json"); - } - catch (Exception e) - { - Log.Exception("|PluginManagement.GetManifest|Encountered error trying to download plugins manifest", e); + var t = Task.Run( + async () => + json = await Http.Get("https://raw.githubusercontent.com/Flow-Launcher/Flow.Launcher.PluginsManifest/main/plugins.json")); - UserPlugins = new List(); - } + t.Wait(); + + UserPlugins = JsonConvert.DeserializeObject>(json); + } + catch (Exception e) + { + Log.Exception("|PluginManagement.GetManifest|Encountered error trying to download plugins manifest", e); + + UserPlugins = new List(); } - UserPlugins = !string.IsNullOrEmpty(json) ? JsonConvert.DeserializeObject>(json) : new List(); } } }