mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-24 09:46:29 +00:00
feat: add download table controls
This commit is contained in:
@@ -55,7 +55,6 @@ final class Aria2DownloadEngine {
|
||||
|
||||
func start(
|
||||
item: DownloadItem,
|
||||
perServerConnections: Int,
|
||||
progress: @escaping @Sendable (DownloadProgress) -> Void,
|
||||
completion: @escaping @Sendable (Result<Void, Error>) -> Void
|
||||
) throws -> Handle {
|
||||
@@ -122,7 +121,7 @@ final class Aria2DownloadEngine {
|
||||
|
||||
do {
|
||||
try process.run()
|
||||
if let input = inputFileContent(for: item, perServerConnections: perServerConnections).data(using: .utf8) {
|
||||
if let input = inputFileContent(for: item).data(using: .utf8) {
|
||||
inputPipe.fileHandleForWriting.write(input)
|
||||
}
|
||||
inputPipe.fileHandleForWriting.closeFile()
|
||||
@@ -151,14 +150,14 @@ final class Aria2DownloadEngine {
|
||||
]
|
||||
}
|
||||
|
||||
private func inputFileContent(for item: DownloadItem, perServerConnections: Int) -> String {
|
||||
let sameHostConnections = min(max(perServerConnections, 1), item.parts)
|
||||
private func inputFileContent(for item: DownloadItem) -> String {
|
||||
let connections = min(max(item.connectionsPerServer, 1), 16)
|
||||
var lines = [
|
||||
sanitizedOptionValue(item.url.absoluteString),
|
||||
" dir=\(sanitizedOptionValue(item.destinationDirectory.path))",
|
||||
" out=\(sanitizedOptionValue(item.fileName))",
|
||||
" split=\(item.parts)",
|
||||
" max-connection-per-server=\(sameHostConnections)"
|
||||
" split=\(connections)",
|
||||
" max-connection-per-server=\(connections)"
|
||||
]
|
||||
|
||||
if let credentials = item.credentials, !credentials.isEmpty {
|
||||
|
||||
Reference in New Issue
Block a user