diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-11-01 19:10:27 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-01 19:10:27 -0500 |
| commit | 69d663c55ae5ad60a3e5120806e2054497eb40e8 (patch) | |
| tree | adfee75613424bbbf9bb3e8e04bc61f26e531d4a /src | |
| parent | fa536c755972040bf0000e95b8cb2d39ea7f1300 (diff) | |
| parent | e5751927adf000306036ee855f7d0316ba18e7d7 (diff) | |
| download | slskd-69d663c55ae5ad60a3e5120806e2054497eb40e8.tar.gz | |
Merge pull request #726 from slskd/paths
Re-upload shares upon controller reconnect, add more logging
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Common/CommonExtensions.cs | 2 | ||||
| -rw-r--r-- | src/slskd/Network/API/Hubs/NetworkHub.cs | 2 | ||||
| -rw-r--r-- | src/slskd/Network/NetworkClient.cs | 4 | ||||
| -rw-r--r-- | src/slskd/Network/NetworkService.cs | 8 |
4 files changed, 13 insertions, 3 deletions
diff --git a/src/slskd/Common/CommonExtensions.cs b/src/slskd/Common/CommonExtensions.cs index ed07f9ea..3ccc72e9 100644 --- a/src/slskd/Common/CommonExtensions.cs +++ b/src/slskd/Common/CommonExtensions.cs @@ -318,7 +318,7 @@ namespace slskd /// <returns></returns> public static string GetNormalizedFileName(this string path) { - return string.Join('\\', path.Split('\\').TakeLast(1)); + return path.Split('\\').TakeLast(1).First(); } /// <summary> diff --git a/src/slskd/Network/API/Hubs/NetworkHub.cs b/src/slskd/Network/API/Hubs/NetworkHub.cs index cf29f15f..fe187909 100644 --- a/src/slskd/Network/API/Hubs/NetworkHub.cs +++ b/src/slskd/Network/API/Hubs/NetworkHub.cs @@ -168,6 +168,8 @@ namespace slskd.Network { if (Network.TryGetAgentRegistration(Context.ConnectionId, out var record)) { + Log.Information("Agent {Agent} (connection {ConnectionId}) returned file info for {Id}; exists: {Exists}, length: {Length}", record.Agent.Name, Context.ConnectionId, id, exists, length); + Network.HandleFileInfoResponse(record.Agent.Name, id, (exists, length)); } diff --git a/src/slskd/Network/NetworkClient.cs b/src/slskd/Network/NetworkClient.cs index 28439287..3afcb633 100644 --- a/src/slskd/Network/NetworkClient.cs +++ b/src/slskd/Network/NetworkClient.cs @@ -321,10 +321,10 @@ namespace slskd.Network return Task.CompletedTask; } - private Task HubConnection_Reconnected(string arg) + private async Task HubConnection_Reconnected(string arg) { Log.Warning("Network controller connection reconnected"); - return Task.CompletedTask; + await UploadSharesAsync(); } private HttpClient CreateHttpClient() diff --git a/src/slskd/Network/NetworkService.cs b/src/slskd/Network/NetworkService.cs index 38437073..65ac05bd 100644 --- a/src/slskd/Network/NetworkService.cs +++ b/src/slskd/Network/NetworkService.cs @@ -353,6 +353,8 @@ namespace slskd.Network var key = new WaitKey(nameof(GetFileInfoAsync), agentName, id); var wait = Waiter.Wait<(bool Exists, long Length)>(key, timeout); + Log.Information("Created wait {Key}", key); + try { await NetworkHub.Clients.Client(record.ConnectionId).RequestFileInfo(filename, id); @@ -427,6 +429,8 @@ namespace slskd.Network var key = new WaitKey(nameof(GetFileStreamAsync), agentName, id); var wait = Waiter.Wait<Stream>(key, timeout, cancellationToken); + Log.Information("Created wait {Key}", key); + await NetworkHub.Clients.Client(record.ConnectionId).RequestFileUpload(filename, id); Log.Information("Requested file {Filename} from Agent {Agent} with ID {Id}. Waiting for incoming connection.", filename, agentName, id); @@ -455,6 +459,8 @@ namespace slskd.Network { var key = new WaitKey(nameof(GetFileInfoAsync), agentName, id); + Log.Information("Handling wait {Key}", key); + if (!Waiter.IsWaitingFor(key)) { var msg = $"A file info response from Agent {agentName} matching Id {id} was not expected"; @@ -480,6 +486,8 @@ namespace slskd.Network { var streamKey = new WaitKey(nameof(GetFileStreamAsync), agentName, id); + Log.Information("Handling wait {Key}", streamKey); + if (!Waiter.IsWaitingFor(streamKey)) { var msg = $"A file stream response matching Id {id} is not expected"; |
