@@ -163,44 +163,26 @@ struct OfficialCertificatesView: View {
163163 . font ( . caption)
164164 }
165165
166- private func fetchTrees( ) {
167- Task {
168- let rootURL = URL ( string: " https://api.github.com/repos/ProStore-iOS/certificates/git/trees/main " ) !
169- do {
170- let ( data, _) = try await URLSession . shared. data ( from: rootURL)
171- let decoder = JSONDecoder ( )
172- let response = try decoder. decode ( TreeResponse . self, from: data)
173-
174- let folders = response. tree. filter { $0. type == " tree " }
175-
176- var validCerts : [ TreeItem ] = [ ]
177-
178- for folder in folders {
179- guard let folderURL = URL ( string: folder. url) else { continue }
180- let ( subData, _) = try await URLSession . shared. data ( from: folderURL)
181- let subTree = try decoder. decode ( TreeResponse . self, from: subData) . tree
182-
183- let hasP12 = subTree. contains { $0. path. hasSuffix ( " .p12 " ) }
184- let hasProv = subTree. contains { $0. path. hasSuffix ( " .mobileprovision " ) }
185- let hasPassword = subTree. contains { $0. path == " password.txt " }
186-
187- if hasP12 && hasProv && hasPassword {
188- validCerts. append ( folder)
166+ private func fetchTrees( ) {
167+ Task {
168+ let url = URL ( string: " https://api.github.com/repos/ProStore-iOS/certificates/git/trees/main " ) !
169+ do {
170+ let ( data, _) = try await URLSession . shared. data ( from: url)
171+ let decoder = JSONDecoder ( )
172+ let response = try decoder. decode ( TreeResponse . self, from: data)
173+ let items = response. tree. filter { $0. type == " tree " } . sorted { $0. path < $1. path }
174+ await MainActor . run {
175+ self . certItems = items
176+ self . isLoadingCerts = false
177+ }
178+ } catch {
179+ await MainActor . run {
180+ self . statusMessage = " Failed to fetch certificates: \( error. localizedDescription) "
181+ self . isLoadingCerts = false
189182 }
190- }
191-
192- await MainActor . run {
193- self . certItems = validCerts. sorted { $0. path < $1. path }
194- self . isLoadingCerts = false
195- }
196- } catch {
197- await MainActor . run {
198- self . statusMessage = " Failed to fetch certificates: \( error. localizedDescription) "
199- self . isLoadingCerts = false
200183 }
201184 }
202185 }
203- }
204186
205187 private func fetchBlobContent( url: URL ) async throws -> Data {
206188 let ( data, _) = try await URLSession . shared. data ( from: url)
@@ -300,5 +282,3 @@ private func fetchTrees() {
300282 }
301283 }
302284}
303-
304-
0 commit comments