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));
|
_httpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("MareSynchronos", ver!.Major + "." + ver!.Minor + "." + ver!.Build));
|
||||||
|
|
||||||
_availableDownloadSlots = mareConfig.Current.ParallelDownloads;
|
_availableDownloadSlots = mareConfig.Current.ParallelDownloads;
|
||||||
_downloadSemaphore = new(_availableDownloadSlots);
|
_downloadSemaphore = new(_availableDownloadSlots, _availableDownloadSlots);
|
||||||
|
|
||||||
Mediator.Subscribe<ConnectedMessage>(this, (msg) =>
|
Mediator.Subscribe<ConnectedMessage>(this, (msg) =>
|
||||||
{
|
{
|
||||||
|
|
@ -72,8 +72,15 @@ public class FileTransferOrchestrator : DisposableMediatorSubscriberBase
|
||||||
|
|
||||||
public void ReleaseDownloadSlot()
|
public void ReleaseDownloadSlot()
|
||||||
{
|
{
|
||||||
_downloadSemaphore.Release();
|
try
|
||||||
Mediator.Publish(new DownloadLimitChangedMessage());
|
{
|
||||||
|
_downloadSemaphore.Release();
|
||||||
|
Mediator.Publish(new DownloadLimitChangedMessage());
|
||||||
|
}
|
||||||
|
catch (SemaphoreFullException)
|
||||||
|
{
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<HttpResponseMessage> SendRequestAsync(HttpMethod method, Uri uri,
|
public async Task<HttpResponseMessage> SendRequestAsync(HttpMethod method, Uri uri,
|
||||||
|
|
@ -107,7 +114,7 @@ public class FileTransferOrchestrator : DisposableMediatorSubscriberBase
|
||||||
if (_availableDownloadSlots != _mareConfig.Current.ParallelDownloads && _availableDownloadSlots == _downloadSemaphore.CurrentCount)
|
if (_availableDownloadSlots != _mareConfig.Current.ParallelDownloads && _availableDownloadSlots == _downloadSemaphore.CurrentCount)
|
||||||
{
|
{
|
||||||
_availableDownloadSlots = _mareConfig.Current.ParallelDownloads;
|
_availableDownloadSlots = _mareConfig.Current.ParallelDownloads;
|
||||||
_downloadSemaphore = new(_availableDownloadSlots);
|
_downloadSemaphore = new(_availableDownloadSlots, _availableDownloadSlots);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue