Add ParallelCount setting back, don't calculate chunk count but use a setting value.
This commit is contained in:
parent
54f1d23181
commit
486cea1006
6 changed files with 38 additions and 40 deletions
|
|
@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [2.0.58] - 2024-01-10
|
||||
### Changed
|
||||
- Don't automatically count the chunk count.
|
||||
|
||||
## [2.0.57] - 2024-01-09
|
||||
### Changed
|
||||
- Fixed symlink retry.
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@
|
|||
<a class="navbar-item" routerLink="profile"> Profile </a>
|
||||
<a class="navbar-item" (click)="logout()"> Logout </a>
|
||||
<hr class="navbar-divider" />
|
||||
<a href="https://github.com/rogerfar/rdt-client" target="_blank" class="navbar-item">Version 2.0.57</a>
|
||||
<a href="https://github.com/rogerfar/rdt-client" target="_blank" class="navbar-item">Version 2.0.58</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "rdt-client",
|
||||
"version": "2.0.57",
|
||||
"version": "2.0.58",
|
||||
"description": "This is a web interface to manage your torrents on Real-Debrid.",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
|
|
|
|||
|
|
@ -95,9 +95,13 @@ public class DbSettingsDownloadClient
|
|||
[Description("Maximum download speed in Megabytes per second. When set to 0 unlimited speed is used.")]
|
||||
public Int32 MaxSpeed { get; set; } = 0;
|
||||
|
||||
[DisplayName("Parallel connections per download (only used for the Internal Downloader)")]
|
||||
[Description("Maximum amount of parallel threads that are used to download a single file to your host. If set to 0 no parallel downloading will be done.")]
|
||||
public Int32 ParallelCount { get; set; } = 4;
|
||||
|
||||
[DisplayName("Chunk Count")]
|
||||
[Description("Split the downloaded file in this amount of chunks. If left to 0, automatically deteremine the chunk size based on the file size.")]
|
||||
public Int32 ChunkCount { get; set; } = 0;
|
||||
[Description("Split the downloaded file in this amount of chunks.")]
|
||||
public Int32 ChunkCount { get; set; } = 8;
|
||||
|
||||
[DisplayName("Connection Timeout (only used for the Internal Downloader)")]
|
||||
[Description("Timeout in milliseconds before the downloader times out.")]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
using System.Net;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using Downloader;
|
||||
using Newtonsoft.Json;
|
||||
using Serilog;
|
||||
|
||||
namespace RdtClient.Service.Services.Downloaders;
|
||||
|
|
@ -64,6 +66,8 @@ public class InternalDownloader : IDownloader
|
|||
return;
|
||||
}
|
||||
|
||||
Debug.WriteLine(JsonConvert.SerializeObject(args));
|
||||
|
||||
DownloadProgress.Invoke(this,
|
||||
new DownloadProgressEventArgs
|
||||
{
|
||||
|
|
@ -96,24 +100,10 @@ public class InternalDownloader : IDownloader
|
|||
};
|
||||
}
|
||||
|
||||
public async Task<String?> Download()
|
||||
public Task<String?> Download()
|
||||
{
|
||||
_logger.Debug($"Starting download of {_uri}, writing to path: {_filePath}");
|
||||
|
||||
if (Settings.Get.DownloadClient.ChunkCount == 0)
|
||||
{
|
||||
var contentSize = await GetContentSize();
|
||||
|
||||
var chunkSize = contentSize switch
|
||||
{
|
||||
<= 1024 * 1024 * 10 => 1024 * 1024 * 10,
|
||||
<= 1024 * 1024 * 100 => 1024 * 1024 * 25,
|
||||
_ => 1024 * 1024 * 50
|
||||
};
|
||||
|
||||
_downloadConfiguration.ChunkCount = (Int32) Math.Ceiling(contentSize / (Double) chunkSize);
|
||||
}
|
||||
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
await _downloadService.DownloadFileTaskAsync(_uri, _filePath);
|
||||
|
|
@ -121,7 +111,7 @@ public class InternalDownloader : IDownloader
|
|||
|
||||
_ = Task.Run(StartTimer);
|
||||
|
||||
return Guid.NewGuid().ToString();
|
||||
return Task.FromResult<String?>(Guid.NewGuid().ToString());
|
||||
}
|
||||
|
||||
public Task Cancel()
|
||||
|
|
@ -160,9 +150,26 @@ public class InternalDownloader : IDownloader
|
|||
{
|
||||
settingDownloadTimeout = 1000;
|
||||
}
|
||||
|
||||
var settingParallelCount = Settings.Get.DownloadClient.ParallelCount;
|
||||
|
||||
if (settingParallelCount <= 0)
|
||||
{
|
||||
settingParallelCount = 4;
|
||||
}
|
||||
|
||||
if (Settings.Get.DownloadClient.ChunkCount <= 0)
|
||||
{
|
||||
_downloadConfiguration.ChunkCount = 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
_downloadConfiguration.ChunkCount = Settings.Get.DownloadClient.ChunkCount;
|
||||
}
|
||||
|
||||
_downloadConfiguration.MaximumBytesPerSecond = settingDownloadMaxSpeed;
|
||||
_downloadConfiguration.ParallelDownload = true;
|
||||
_downloadConfiguration.ParallelDownload = settingParallelCount > 1;
|
||||
_downloadConfiguration.ParallelCount = settingParallelCount;
|
||||
_downloadConfiguration.Timeout = settingDownloadTimeout;
|
||||
}
|
||||
|
||||
|
|
@ -180,21 +187,4 @@ public class InternalDownloader : IDownloader
|
|||
SetSettings();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<Int64> GetContentSize()
|
||||
{
|
||||
var httpClient = new HttpClient();
|
||||
var responseHeaders = await httpClient.SendAsync(new HttpRequestMessage(HttpMethod.Head, _uri));
|
||||
|
||||
if (!responseHeaders.IsSuccessStatusCode)
|
||||
{
|
||||
var content = await responseHeaders.Content.ReadAsStringAsync();
|
||||
var ex = new Exception($"Unable to retrieve content size before downloading, received response: {responseHeaders.StatusCode} {content}");
|
||||
|
||||
throw ex;
|
||||
}
|
||||
|
||||
var result = responseHeaders.Content.Headers.ContentLength ?? -1;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
<TargetFramework>net8.0</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
<UserSecretsId>94c24cba-f03f-4453-a671-3640b517c573</UserSecretsId>
|
||||
<Version>2.0.57</Version>
|
||||
<Version>2.0.58</Version>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<LangVersion>latest</LangVersion>
|
||||
|
|
|
|||
Loading…
Reference in a new issue