mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-12 21:57:22 +01:00
fix negative download limit maybe
This commit is contained in:
parent
6ef896710e
commit
00fdba1c4b
1 changed files with 11 additions and 4 deletions
|
|
@ -34,7 +34,7 @@ public class FileTransferOrchestrator : DisposableMediatorSubscriberBase
|
|||
_httpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("MareSynchronos", ver!.Major + "." + ver!.Minor + "." + ver!.Build));
|
||||
|
||||
_availableDownloadSlots = mareConfig.Current.ParallelDownloads;
|
||||
_downloadSemaphore = new(_availableDownloadSlots);
|
||||
_downloadSemaphore = new(_availableDownloadSlots, _availableDownloadSlots);
|
||||
|
||||
Mediator.Subscribe<ConnectedMessage>(this, (msg) =>
|
||||
{
|
||||
|
|
@ -71,10 +71,17 @@ public class FileTransferOrchestrator : DisposableMediatorSubscriberBase
|
|||
}
|
||||
|
||||
public void ReleaseDownloadSlot()
|
||||
{
|
||||
try
|
||||
{
|
||||
_downloadSemaphore.Release();
|
||||
Mediator.Publish(new DownloadLimitChangedMessage());
|
||||
}
|
||||
catch (SemaphoreFullException)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<HttpResponseMessage> SendRequestAsync(HttpMethod method, Uri uri,
|
||||
CancellationToken? ct = null, HttpCompletionOption httpCompletionOption = HttpCompletionOption.ResponseContentRead)
|
||||
|
|
@ -107,7 +114,7 @@ public class FileTransferOrchestrator : DisposableMediatorSubscriberBase
|
|||
if (_availableDownloadSlots != _mareConfig.Current.ParallelDownloads && _availableDownloadSlots == _downloadSemaphore.CurrentCount)
|
||||
{
|
||||
_availableDownloadSlots = _mareConfig.Current.ParallelDownloads;
|
||||
_downloadSemaphore = new(_availableDownloadSlots);
|
||||
_downloadSemaphore = new(_availableDownloadSlots, _availableDownloadSlots);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue