From e301ad881861135a9fa45bfefe3aabaf458b0850 Mon Sep 17 00:00:00 2001 From: Brandon Evans Date: Thu, 18 Feb 2021 19:14:44 -0700 Subject: [PATCH] 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. --- Xcodes/Backend/Environment.swift | 4 +++- Xcodes/Backend/Progress+.swift | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Xcodes/Backend/Environment.swift b/Xcodes/Backend/Environment.swift index 71a753d..1093aa4 100644 --- a/Xcodes/Backend/Environment.swift +++ b/Xcodes/Backend/Environment.swift @@ -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, diff --git a/Xcodes/Backend/Progress+.swift b/Xcodes/Backend/Progress+.swift index 0998369..61d26e2 100644 --- a/Xcodes/Backend/Progress+.swift +++ b/Xcodes/Backend/Progress+.swift @@ -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) } }