mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Use System.Text.JsonSerializer.DeserializeAsync instead of Newtonsoft.Json since our plugins.json can be large, so no need to create an extra string to store it.
This commit is contained in:
parent
bb9682f791
commit
f32e202746
2 changed files with 17 additions and 4 deletions
|
|
@ -73,5 +73,18 @@ namespace Flow.Launcher.Infrastructure.Http
|
|||
|
||||
return content;
|
||||
}
|
||||
|
||||
public static async Task<Stream> GetStreamAsync([NotNull] string url, string encoding = "UTF-8")
|
||||
{
|
||||
Log.Debug($"|Http.Get|Url <{url}>");
|
||||
var request = WebRequest.CreateHttp(url);
|
||||
request.Method = "GET";
|
||||
request.Timeout = 6000;
|
||||
request.Proxy = WebProxy();
|
||||
request.UserAgent = UserAgent;
|
||||
var response = await request.GetResponseAsync() as HttpWebResponse;
|
||||
response = response.NonNull();
|
||||
return response.GetResponseStream().NonNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
using Flow.Launcher.Infrastructure.Http;
|
||||
using Flow.Launcher.Infrastructure.Logger;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Flow.Launcher.Plugin.PluginsManager.Models
|
||||
|
|
@ -17,12 +17,12 @@ namespace Flow.Launcher.Plugin.PluginsManager.Models
|
|||
|
||||
internal async Task DownloadManifest()
|
||||
{
|
||||
var json = string.Empty;
|
||||
try
|
||||
{
|
||||
json = await Http.Get("https://raw.githubusercontent.com/Flow-Launcher/Flow.Launcher.PluginsManifest/main/plugins.json");
|
||||
var jsonStream = await Http.GetStreamAsync("https://raw.githubusercontent.com/Flow-Launcher/Flow.Launcher.PluginsManifest/main/plugins.json")
|
||||
.ConfigureAwait(false);
|
||||
|
||||
UserPlugins = JsonConvert.DeserializeObject<List<UserPlugin>>(json);
|
||||
UserPlugins = await JsonSerializer.DeserializeAsync<List<UserPlugin>>(jsonStream).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue