@@ -41,7 +41,8 @@ struct VirtualBuddyFetcher: DataSourceFetcher, Sendable {
4141 typealias Record = [ RestoreImageRecord ]
4242
4343 /// Base URL components for VirtualBuddy TSS API endpoint
44- private static let baseURLComponents = URLComponents ( string: " https://tss.virtualbuddy.app/v1/status " ) !
44+ private static let baseURLComponents = URLComponents (
45+ string: " https://tss.virtualbuddy.app/v1/status " ) !
4546
4647 private let apiKey : String
4748 private let decoder : JSONDecoder
@@ -52,29 +53,19 @@ struct VirtualBuddyFetcher: DataSourceFetcher, Sendable {
5253 guard let key = ProcessInfo . processInfo. environment [ " VIRTUALBUDDY_API_KEY " ] , !key. isEmpty else {
5354 return nil
5455 }
55- self . apiKey = key
56- self . decoder = JSONDecoder ( )
57- #if canImport(FoundationNetworking)
58- self . urlSession = FoundationNetworking . URLSession. shared
59- #else
60- self . urlSession = URLSession . shared
61- #endif
56+ self . init ( apiKey: key)
6257 }
6358
6459 /// Explicit initializer with API key
6560 init ( apiKey: String , decoder: JSONDecoder = JSONDecoder ( ) , urlSession: URLSession = . shared) {
6661 self . apiKey = apiKey
6762 self . decoder = decoder
68- #if canImport(FoundationNetworking)
69- self . urlSession = FoundationNetworking . URLSession. shared
70- #else
71- self . urlSession = urlSession
72- #endif
63+ self . urlSession = urlSession
7364 }
7465
7566 /// DataSourceFetcher protocol requirement - returns empty for enrichment fetchers
7667 func fetch( ) async throws -> [ RestoreImageRecord ] {
77- return [ ]
68+ [ ]
7869 }
7970
8071 /// Enrich existing restore images with VirtualBuddy TSS signing status
@@ -117,11 +108,15 @@ struct VirtualBuddyFetcher: DataSourceFetcher, Sendable {
117108 // Show result with signing status
118109 let statusEmoji = response. isSigned ? " ✅ " : " ❌ "
119110 let statusText = response. isSigned ? " signed " : " unsigned "
120- print ( " \( statusEmoji) VirtualBuddy: \( image. buildNumber) - \( statusText) ( \( processedCount) / \( totalCount) ) " )
111+ print (
112+ " \( statusEmoji) VirtualBuddy: \( image. buildNumber) - \( statusText) ( \( processedCount) / \( totalCount) ) "
113+ )
121114
122115 enrichedImages. append ( enriched)
123116 } catch {
124- print ( " ⚠️ VirtualBuddy: \( image. buildNumber) - error: \( error) ( \( processedCount) / \( totalCount) ) " )
117+ print (
118+ " ⚠️ VirtualBuddy: \( image. buildNumber) - error: \( error) ( \( processedCount) / \( totalCount) ) "
119+ )
125120 enrichedImages. append ( image) // Keep original on error
126121 }
127122
@@ -142,7 +137,7 @@ struct VirtualBuddyFetcher: DataSourceFetcher, Sendable {
142137 var components = Self . baseURLComponents
143138 components. queryItems = [
144139 URLQueryItem ( name: " apiKey " , value: apiKey) ,
145- URLQueryItem ( name: " ipsw " , value: ipswURL. absoluteString)
140+ URLQueryItem ( name: " ipsw " , value: ipswURL. absoluteString) ,
146141 ]
147142
148143 guard let endpointURL = components. url else {
@@ -153,11 +148,7 @@ struct VirtualBuddyFetcher: DataSourceFetcher, Sendable {
153148 let data : Data
154149 let response : URLResponse
155150 do {
156- #if canImport(FoundationNetworking)
157- ( data, response) = try await urlSession. data ( from: endpointURL)
158- #else
159- ( data, response) = try await urlSession. data ( from: endpointURL)
160- #endif
151+ ( data, response) = try await urlSession. data ( from: endpointURL)
161152 } catch {
162153 throw VirtualBuddyFetcherError . networkError ( error)
163154 }
0 commit comments