Fix main-thread blocking I/O

This commit is contained in:
世界
2026-02-05 02:37:02 +08:00
parent 4ae421cd04
commit 2e682d746c
17 changed files with 643 additions and 237 deletions
+9 -7
View File
@@ -7,21 +7,23 @@ public extension Profile {
if type != .remote {
return
}
let remoteContent = try HTTPClient().getString(remoteURL)
var error: NSError?
LibboxCheckConfig(remoteContent, &error)
if let error {
throw error
let remoteContent = try await HTTPClient.getStringAsync(remoteURL)
try await BlockingIO.run {
var error: NSError?
LibboxCheckConfig(remoteContent, &error)
if let error {
throw error
}
}
lastUpdated = Date()
try await ProfileManager.update(self)
do {
let oldContent = try read()
let oldContent = try await readAsync()
if oldContent == remoteContent {
return
}
} catch {}
try write(remoteContent)
try await writeAsync(remoteContent)
try await onProfileUpdated()
}