Configure aria2c Progress better

Using .file kind and .downloading file operation kind will produce a more appropriate localizedAdditionalDescription.

The fileTotalCount and fileCompletedCount aren't appropriate for this case, because there's only one file being downloaded.
This commit is contained in:
Brandon Evans 2021-02-18 19:14:44 -07:00
parent d00a356c29
commit e301ad8818
No known key found for this signature in database
GPG key ID: D58A4B8DB64F8E93
2 changed files with 3 additions and 3 deletions

View file

@ -53,7 +53,9 @@ public struct Shell {
let stdErrPipe = Pipe()
process.standardError = stdErrPipe
var progress = Progress(totalUnitCount: 100)
var progress = Progress()
progress.kind = .file
progress.fileOperationKind = .downloading
let observer = NotificationCenter.default.addObserver(
forName: .NSFileHandleDataAvailable,

View file

@ -12,7 +12,6 @@ extension Progress {
if let match = regexTotalDownloaded.firstMatch(in: string, options: [], range: range),
let matchRange = Range(match.range(at: 0), in: string),
let totalDownloaded = Int(string[matchRange].replacingOccurrences(of: "B", with: "")) {
self.fileCompletedCount = totalDownloaded
self.completedUnitCount = Int64(totalDownloaded)
}
@ -24,7 +23,6 @@ extension Progress {
let totalFileSize = Int(string[matchRange].replacingOccurrences(of: "B", with: "")) {
if totalFileSize > 0 {
self.fileTotalCount = totalFileSize
self.totalUnitCount = Int64(totalFileSize)
}
}