diff options
| author | JP Dillingham <jp@dillingham.me> | 2023-01-08 16:02:58 -0600 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2023-01-08 16:02:58 -0600 |
| commit | 5a5621a74daa99cd3b98815924f5bb8c24fd9db0 (patch) | |
| tree | 90a15266ea35a5d48bcc69e9c80d74a6e09c6cc9 /src/slskd/Relay/RelayClient.cs | |
| parent | a37b61767410fea15aa8cf57c944ea23c495f6d4 (diff) | |
| download | slskd-5a5621a74daa99cd3b98815924f5bb8c24fd9db0.tar.gz | |
add back upload of shares on reconnect
Diffstat (limited to 'src/slskd/Relay/RelayClient.cs')
| -rw-r--r-- | src/slskd/Relay/RelayClient.cs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/slskd/Relay/RelayClient.cs b/src/slskd/Relay/RelayClient.cs index 58bda800..38d8446a 100644 --- a/src/slskd/Relay/RelayClient.cs +++ b/src/slskd/Relay/RelayClient.cs @@ -515,7 +515,7 @@ namespace slskd.Relay return Task.CompletedTask; } - private Task HubConnection_Reconnected(string arg) + private async Task HubConnection_Reconnected(string arg) { // upon reconnection, the authentication flow is started again. this may happen before the client // realizes the connection has been closed, so reset everything as though we're just learning that @@ -523,7 +523,28 @@ namespace slskd.Relay ResetLoggedInState(); Log.Warning("Relay controller connection reconnected"); - return Task.CompletedTask; + + try + { + // wait for the authentication flow to complete + // time out after 5 seconds in case we get stuck waiting on a dead Task + await LoggedInTaskCompletionSource.Task; + + Log.Information("Uploading shares..."); + + await UploadSharesAsync(); + } + catch (Exception ex) + { + Log.Error(ex, ex.Message); + Log.Error("Disconnecting from the relay controller"); + + // stop, then fire and forget StartAsync() to re-enter the connection retry loop + await StopAsync(); + _ = StartAsync(); + } + + Log.Information("Shares uploaded. Ready to relay files."); } private Task HubConnection_Reconnecting(Exception arg) |
