From b9ef6503d244ec16be84fc43c23e9d9b741213a0 Mon Sep 17 00:00:00 2001 From: rootdarkarchon Date: Sat, 20 Jan 2024 00:05:55 +0100 Subject: [PATCH] make sure to resend the data --- .../WebAPI/Files/FileTransferOrchestrator.cs | 13 +++++++++++-- .../WebAPI/SignalR/ApIController.Functions.Users.cs | 1 + MareSynchronos/WebAPI/SignalR/ApiController.cs | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/MareSynchronos/WebAPI/Files/FileTransferOrchestrator.cs b/MareSynchronos/WebAPI/Files/FileTransferOrchestrator.cs index f1764c6..3282cd5 100644 --- a/MareSynchronos/WebAPI/Files/FileTransferOrchestrator.cs +++ b/MareSynchronos/WebAPI/Files/FileTransferOrchestrator.cs @@ -126,8 +126,17 @@ public class FileTransferOrchestrator : DisposableMediatorSubscriberBase MareConfiguration.Models.DownloadSpeeds.MBps => limit * 1024 * 1024, _ => limit, }; - var dividedLimit = limit / (CurrentlyUsedDownloadSlots == 0 ? 1 : CurrentlyUsedDownloadSlots); - return dividedLimit == 0 ? 1 : dividedLimit; + var currentUsedDlSlots = CurrentlyUsedDownloadSlots; + var avaialble = _availableDownloadSlots; + var currentCount = _downloadSemaphore.CurrentCount; + var dividedLimit = limit / (currentUsedDlSlots == 0 ? 1 : currentUsedDlSlots); + if (dividedLimit < 0) + { + Logger.LogWarning("Calculated Bandwidth Limit is negative, returning Infinity: {value}, CurrentlyUsedDownloadSlots is {currentSlots}, " + + "DownloadSpeedLimit is {limit}, available slots: {avail}, current count: {count}", dividedLimit, currentUsedDlSlots, limit, avaialble, currentCount); + return long.MaxValue; + } + return Math.Clamp(dividedLimit, 1, long.MaxValue); } private async Task SendRequestInternalAsync(HttpRequestMessage requestMessage, diff --git a/MareSynchronos/WebAPI/SignalR/ApIController.Functions.Users.cs b/MareSynchronos/WebAPI/SignalR/ApIController.Functions.Users.cs index 819c69f..266d42f 100644 --- a/MareSynchronos/WebAPI/SignalR/ApIController.Functions.Users.cs +++ b/MareSynchronos/WebAPI/SignalR/ApIController.Functions.Users.cs @@ -16,6 +16,7 @@ public partial class ApiController try { + Logger.LogDebug("Pushing Character data {hash} to {visible}", data.DataHash, string.Join(", ", visibleCharacters.Select(v => v.AliasOrUID))); await PushCharacterDataInternal(data, [.. visibleCharacters]).ConfigureAwait(false); } catch (OperationCanceledException) diff --git a/MareSynchronos/WebAPI/SignalR/ApiController.cs b/MareSynchronos/WebAPI/SignalR/ApiController.cs index 49b25b2..4fadd08 100644 --- a/MareSynchronos/WebAPI/SignalR/ApiController.cs +++ b/MareSynchronos/WebAPI/SignalR/ApiController.cs @@ -406,6 +406,7 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM } await LoadIninitialPairs().ConfigureAwait(false); await LoadOnlinePairs().ConfigureAwait(false); + Mediator.Publish(new ConnectedMessage(_connectionDto)); } catch (Exception ex) {