PR Cleanup.

This commit is contained in:
Matt Kiazyk 2023-12-01 10:05:36 -06:00
parent c153a93b1b
commit c1836a78c4
3 changed files with 2 additions and 95 deletions

View file

@ -65,26 +65,6 @@ extension AppState {
}
}
}
// self.runtimePublishers[runtime.identifier] = downloadRunTimeFull(runtime: runtime)
// .receive(on: DispatchQueue.main)
// .sink(
// receiveCompletion: { [unowned self] completion in
// self.runtimePublishers[runtime.identifier] = nil
// if case let .failure(error) = completion {
// Logger.appState.error("Error downloading runtime: \(error.localizedDescription)")
//// // Prevent setting the app state error if it is an invalid session, we will present the sign in view instead
//// if error as? AuthenticationError != .invalidSession {
//// self.error = error
//// self.presentedAlert = .generic(title: localizeString("Alert.Install.Error.Title"), message: error.legibleLocalizedDescription)
//// }
//// if let index = self.allXcodes.firstIndex(where: { $0.id == id }) {
//// self.allXcodes[index].installState = .notInstalled
//// }
// }
// },
// receiveValue: { _ in }
// )
}
func downloadRunTimeFull(runtime: DownloadableRuntime) async throws {
@ -126,7 +106,6 @@ extension AppState {
// use runtime.url for final with cookies
// Check to see if the archive is in the expected path in case it was downloaded but failed to install
// let expectedRuntimePath = Path.xcodesApplicationSupport/"\(runtime.name).\(runtime.name.suffix(fromLast: "."))"
let url = URL(string: runtime.source)!
let expectedRuntimePath = Path.xcodesApplicationSupport/"\(url.lastPathComponent)"
// aria2 downloads directly to the destination (instead of into /tmp first) so we need to make sure that the download isn't incomplete
@ -158,12 +137,6 @@ extension AppState {
return Just(runtime.url)
.setFailureType(to: Error.self)
.eraseToAnyPublisher()
// return downloadRuntimeWithURLSession(
// runtime,
// to: expectedRuntimePath,
// progressChanged: progressChanged
// )
}
}
}

View file

@ -111,74 +111,9 @@ public struct Shell {
return (progress, publisher)
}
// TODO: Support using aria2 using AysncStream/AsyncSequence
// public var downloadWithAria2Async: (Path, URL, Path, [HTTPCookie]) async throws -> Progress = { aria2Path, url, destination, cookies in
// let process = Process()
// process.executableURL = aria2Path.url
// process.arguments = [
// "--header=Cookie: \(cookies.map { "\($0.name)=\($0.value)" }.joined(separator: "; "))",
// "--max-connection-per-server=16",
// "--split=16",
// "--summaraasdy-interval=1",
// "--stop-with-process=\(ProcessInfo.processInfo.processIdentifier)", // if xcodes quits, stop aria2 process
// "--dir=\(destination.parent.string)",
// "--out=\(destination.basename())",
// "--human-readable=false", // sets the output to use bytes instead of formatting
// url.absoluteString,
// ]
// let stdOutPipe = Pipe()
// process.standardOutput = stdOutPipe
// let stdErrPipe = Pipe()
// process.standardError = stdErrPipe
//
// var progress = Progress()
// progress.kinasdas
// progress.fileOperationKind = .downloadingasdfasd
//
// let observer = NotificationCenter.default.addObserver(
// forName: .NSFileHandleDataAvailable,
// object: nil,
// queue: OperationQueue.main
// ) { note in
// guard
// // This should always be the case for Notification.Name.NSFileHandleDataAvailable
// let handle = note.object as? FileHandle,
// handle === stdOutPipe.fileHandleForReading || handle === stdErrPipe.fileHandleForReading
// else { return }
//
// defer { handle.waitForDataInBackgroundAndNotify() }
//
// let string = String(decoding: handle.availableData, as: UTF8.self)
//
// progress.updateFromAria2(string: string)
// }
//
// stdOutPipe.fileHandleForReading.waitForDataInBackgroundAndNotify()
// stdErrPipe.fileHandleForReading.waitForDataInBackgroundAndNotify()
//
// do {
//
// defer {
// //DispatchQueue.global(qos: .default).async {
// process.waitUntilExit()
//
// NotificationCenter.default.removeObserver(observer, name: .NSFileHandleDataAvailable, object: nil)
//
// guard process.terminationReason == .exit, process.terminationStatus == 0 else {
// if let aria2cError = Aria2CError(exitStatus: process.terminationStatus) {
// throw aria2cError
// } else {
// throw ProcessExecutionError(process: process, standardOutput: "", standardError: "")
// }
// }
// return
// }
// }
// try process.run()
// } catch {
// throw error
// }
// }
public var unxipExperiment: (URL) -> AnyPublisher<ProcessOutput, Error> = { url in
let unxipPath = Path(url: Bundle.main.url(forAuxiliaryExecutable: "unxip")!)!

View file

@ -24,7 +24,6 @@ struct RuntimesView: View {
$0.sdkBuildUpdate == sdkBuild
}
}
// let runtimes = appState.getRunTimes(xcode: xcode)
ForEach(runtimes ?? [], id: \.simulatorVersion.buildUpdate) { runtime in
VStack {