mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Code quality
This commit is contained in:
parent
9b5d22a442
commit
0d9ec48e58
2 changed files with 9 additions and 10 deletions
|
|
@ -19,7 +19,7 @@ namespace Flow.Launcher.Core.ExternalPlugins
|
||||||
|
|
||||||
private List<UserPlugin> plugins = new();
|
private List<UserPlugin> plugins = new();
|
||||||
|
|
||||||
private static JsonSerializerOptions PluginStoreItemSerializationOption = new JsonSerializerOptions()
|
private static readonly JsonSerializerOptions PluginStoreItemSerializationOption = new()
|
||||||
{
|
{
|
||||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault
|
||||||
};
|
};
|
||||||
|
|
@ -45,18 +45,18 @@ namespace Flow.Launcher.Core.ExternalPlugins
|
||||||
|
|
||||||
if (response.StatusCode == HttpStatusCode.OK)
|
if (response.StatusCode == HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
this.plugins = await response.Content
|
plugins = await response.Content
|
||||||
.ReadFromJsonAsync<List<UserPlugin>>(PluginStoreItemSerializationOption, cancellationToken: token)
|
.ReadFromJsonAsync<List<UserPlugin>>(PluginStoreItemSerializationOption, cancellationToken: token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
this.latestEtag = response.Headers.ETag?.Tag;
|
latestEtag = response.Headers.ETag?.Tag;
|
||||||
|
|
||||||
Log.Info(nameof(CommunityPluginSource), $"Loaded {this.plugins.Count} plugins from {ManifestFileUrl}");
|
Log.Info(nameof(CommunityPluginSource), $"Loaded {plugins.Count} plugins from {ManifestFileUrl}");
|
||||||
return this.plugins;
|
return plugins;
|
||||||
}
|
}
|
||||||
else if (response.StatusCode == HttpStatusCode.NotModified)
|
else if (response.StatusCode == HttpStatusCode.NotModified)
|
||||||
{
|
{
|
||||||
Log.Info(nameof(CommunityPluginSource), $"Resource {ManifestFileUrl} has not been modified.");
|
Log.Info(nameof(CommunityPluginSource), $"Resource {ManifestFileUrl} has not been modified.");
|
||||||
return this.plugins;
|
return plugins;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -16,15 +16,14 @@ namespace Flow.Launcher.Infrastructure.Http
|
||||||
{
|
{
|
||||||
private const string UserAgent = @"Mozilla/5.0 (Trident/7.0; rv:11.0) like Gecko";
|
private const string UserAgent = @"Mozilla/5.0 (Trident/7.0; rv:11.0) like Gecko";
|
||||||
|
|
||||||
private static HttpClient client = new HttpClient();
|
private static readonly HttpClient client = new();
|
||||||
|
|
||||||
static Http()
|
static Http()
|
||||||
{
|
{
|
||||||
// need to be added so it would work on a win10 machine
|
// need to be added so it would work on a win10 machine
|
||||||
ServicePointManager.Expect100Continue = true;
|
ServicePointManager.Expect100Continue = true;
|
||||||
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls
|
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls
|
||||||
| SecurityProtocolType.Tls11
|
| SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
|
||||||
| SecurityProtocolType.Tls12;
|
|
||||||
|
|
||||||
client.DefaultRequestHeaders.Add("User-Agent", UserAgent);
|
client.DefaultRequestHeaders.Add("User-Agent", UserAgent);
|
||||||
HttpClient.DefaultProxy = WebProxy;
|
HttpClient.DefaultProxy = WebProxy;
|
||||||
|
|
@ -72,7 +71,7 @@ namespace Flow.Launcher.Infrastructure.Http
|
||||||
ProxyProperty.Port => (new Uri($"http://{Proxy.Server}:{Proxy.Port}"), WebProxy.Credentials),
|
ProxyProperty.Port => (new Uri($"http://{Proxy.Server}:{Proxy.Port}"), WebProxy.Credentials),
|
||||||
ProxyProperty.UserName => (WebProxy.Address, new NetworkCredential(Proxy.UserName, Proxy.Password)),
|
ProxyProperty.UserName => (WebProxy.Address, new NetworkCredential(Proxy.UserName, Proxy.Password)),
|
||||||
ProxyProperty.Password => (WebProxy.Address, new NetworkCredential(Proxy.UserName, Proxy.Password)),
|
ProxyProperty.Password => (WebProxy.Address, new NetworkCredential(Proxy.UserName, Proxy.Password)),
|
||||||
_ => throw new ArgumentOutOfRangeException()
|
_ => throw new ArgumentOutOfRangeException(null)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
catch (UriFormatException e)
|
catch (UriFormatException e)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue