aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2022-10-18 09:31:44 -0500
committerJP Dillingham <jp@dillingham.me>2022-10-18 09:31:44 -0500
commit35f1eb3bc76beea198abd3b1489346aaaffc6ba3 (patch)
tree67a58464e9b82e1a5531ef1e4754c4fe7da31621 /src
parent84477c329d35add265cab047cc37bda44f61ab0f (diff)
parent6e77cf20e1ca7548bb27922324592517cebf7883 (diff)
downloadslskd-35f1eb3bc76beea198abd3b1489346aaaffc6ba3.tar.gz
Merge branch 'clear-uploads' of github.com:slskd/slskd into clear-uploads
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Network/NetworkClient.cs17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/slskd/Network/NetworkClient.cs b/src/slskd/Network/NetworkClient.cs
index baaa1250..a231dad2 100644
--- a/src/slskd/Network/NetworkClient.cs
+++ b/src/slskd/Network/NetworkClient.cs
@@ -25,7 +25,6 @@ namespace slskd.Network
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.SignalR.Client;
- using Microsoft.Data.Sqlite;
using Serilog;
using slskd.Cryptography;
using slskd.Shares;
@@ -58,7 +57,6 @@ namespace slskd.Network
private string LastOptionsHash { get; set; }
private IOptionsMonitor<Options> OptionsMonitor { get; }
private IHttpClientFactory HttpClientFactory { get; }
- private HttpClient HttpClient { get; set; }
private HubConnection HubConnection { get; set; }
private bool StartRequested { get; set; }
private CancellationTokenSource StartCancellationTokenSource { get; set; }
@@ -146,7 +144,7 @@ namespace slskd.Network
request.Content = content;
Log.Information("Beginning upload of shares");
- var response = await HttpClient.SendAsync(request);
+ var response = await CreateHttpClient().SendAsync(request);
if (!response.IsSuccessStatusCode)
{
@@ -182,7 +180,7 @@ namespace slskd.Network
request.Content = content;
Log.Information("Beginning upload of file {Filename} with ID {Id}", filename, id);
- var response = await HttpClient.SendAsync(request);
+ var response = await CreateHttpClient().SendAsync(request);
if (!response.IsSuccessStatusCode)
{
@@ -271,6 +269,14 @@ namespace slskd.Network
return Task.CompletedTask;
}
+ private HttpClient CreateHttpClient()
+ {
+ var client = new HttpClient();
+ client.Timeout = TimeSpan.FromMilliseconds(int.MaxValue);
+ client.BaseAddress = new(OptionsMonitor.CurrentValue.Network.Controller.Address);
+ return client;
+ }
+
private void Configure(Options options)
{
if (options.Network.OperationMode.ToEnum<NetworkOperationMode>() != NetworkOperationMode.Agent && !options.Flags.DualNetworkMode)
@@ -296,9 +302,6 @@ namespace slskd.Network
// the retry loop around connection to stop.
StartCancellationTokenSource?.Cancel();
- HttpClient = HttpClientFactory.CreateClient();
- HttpClient.BaseAddress = new(options.Network.Controller.Address);
-
HubConnection = new HubConnectionBuilder()
.WithUrl($"{options.Network.Controller.Address}/hub/agents")
.WithAutomaticReconnect(new[]