@@ -57,6 +57,9 @@ extension AppState {
5757 self . setInstallationStep ( of: runtime, to: . installing)
5858 }
5959 switch runtime. contentType {
60+ case . cryptexDiskImage:
61+ // not supported yet (do we need to for old packages?)
62+ throw " Installing via cryptexDiskImage not support - please install manually from \( downloadedURL. description) "
6063 case . package :
6164 // not supported yet (do we need to for old packages?)
6265 throw " Installing via package not support - please install manually from \( downloadedURL. description) "
@@ -80,19 +83,31 @@ extension AppState {
8083 Logger . appState. error ( " Error downloading runtime: \( error. localizedDescription) " )
8184 DispatchQueue . main. async {
8285 self . error = error
83- self . presentedAlert = . generic( title: localizeString ( " Alert.Install.Error.Title " ) , message: error. legibleLocalizedDescription)
86+ if let error = error as? String {
87+ self . presentedAlert = . generic( title: localizeString ( " Alert.Install.Error.Title " ) , message: error)
88+ } else {
89+ self . presentedAlert = . generic( title: localizeString ( " Alert.Install.Error.Title " ) , message: error. legibleLocalizedDescription)
90+ }
8491 }
8592 }
8693 }
8794 }
8895
8996 func downloadRunTimeFull( runtime: DownloadableRuntime ) async throws -> URL {
97+ guard let source = runtime. source else {
98+ throw " Invalid runtime source "
99+ }
100+
101+ guard let downloadPath = runtime. downloadPath else {
102+ throw " Invalid runtime downloadPath "
103+ }
104+
90105 // sets a proper cookie for runtimes
91- try await validateADCSession ( path: runtime . downloadPath)
106+ try await validateADCSession ( path: downloadPath)
92107
93108 let downloader = Downloader ( rawValue: UserDefaults . standard. string ( forKey: " downloader " ) ?? " aria2 " ) ?? . aria2
94109
95- let url = URL ( string: runtime . source) !
110+ let url = URL ( string: source) !
96111 let expectedRuntimePath = Path . xcodesApplicationSupport/ " \( url. lastPathComponent) "
97112 // aria2 downloads directly to the destination (instead of into /tmp first) so we need to make sure that the download isn't incomplete
98113 let aria2DownloadMetadataPath = expectedRuntimePath. parent/ ( expectedRuntimePath. basename ( ) + " .aria2 " )
@@ -123,9 +138,15 @@ extension AppState {
123138 }
124139
125140 public func downloadRuntimeWithAria2( _ runtime: DownloadableRuntime , to destination: Path , aria2Path: Path ) -> AsyncThrowingStream < Progress , Error > {
126- let cookies = AppleAPI . Current. network. session. configuration. httpCookieStorage? . cookies ( for: runtime. url) ?? [ ]
141+ guard let url = runtime. url else {
142+ return AsyncThrowingStream < Progress , Error > { continuation in
143+ continuation. finish ( throwing: " Invalid or non existant runtime url " )
144+ }
145+ }
146+
147+ let cookies = AppleAPI . Current. network. session. configuration. httpCookieStorage? . cookies ( for: url) ?? [ ]
127148
128- return Current . shell. downloadWithAria2Async ( aria2Path, runtime . url, destination, cookies)
149+ return Current . shell. downloadWithAria2Async ( aria2Path, url, destination, cookies)
129150 }
130151
131152
@@ -140,7 +161,10 @@ extension AppState {
140161 runtimePublishers [ runtime. identifier] = nil
141162
142163 // If the download is cancelled by the user, clean up the download files that aria2 creates.
143- let url = URL ( string: runtime. source) !
164+ guard let source = runtime. source else {
165+ return
166+ }
167+ let url = URL ( string: source) !
144168 let expectedRuntimePath = Path . xcodesApplicationSupport/ " \( url. lastPathComponent) "
145169 let aria2DownloadMetadataPath = expectedRuntimePath. parent/ ( expectedRuntimePath. basename ( ) + " .aria2 " )
146170
0 commit comments